I need to change the Sprite texture in scene 2 using the button that will be in the scene 1

You need a node path in order to access the scene. It works the same as accessing objects.

So something like this near the top of the script on the scene 1 button:

onready var my_sprite = get_node("/root/Game/Scene2/Sprite")
var new_texture = preload("res://new_texture.jpg")

On this pressed function of the button:

my_sprite.texture = new_texture

Hope that helps.

In my case it doesn't work. Node path is in a different floder the button is in the selectpicture folder, and the sprite is in scene draw

When you get the node in GDScript (using get_node), the path is the path inside the scene list, not the resource list. When you are loading a resource, like an image, then you would use the resource path. It shouldn't matter what folder anything is in, as you type the path to whatever folder you like.

3 years later