Changing code script

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By ibo348

how can i change the “var change=0” code,
i want change=1
with remote script, change.gd

change

you need to call the node itself… you cant just write the name of the script and expect it to work…
for example if the node holding script.gd is named “bob” you will need to write $bob.change = 1

rustyStriker | 2018-02-10 16:14

:bust_in_silhouette: Reply From: hilfazer

In change.gd use single “=”, like this:

script.change = 1

you did not understand me

ibo348 | 2018-02-10 15:00

:bust_in_silhouette: Reply From: ibo348

enter image description here

Using global variable, with singleton:
Singletons (AutoLoad) — Godot Engine (3.0) documentation in English

-j

jospic | 2018-02-10 16:53

do you have a sample project

ibo348 | 2018-02-10 17:27

:bust_in_silhouette: Reply From: razah

in change.gd

 extends Node2D
    onready var script = get_node("NodeWith-script.gd")
    
    func _ready():
    	script.change = 2

or using singleton.