I'm trying to replace one sprite texture with another in a script. I've tried using load and preload, in combinations with "texture =" and the set_texture function. I check in the Remote scene tree, and it shows that the correct sprite is loaded into the variable I assigned it to, and I put a print statement immediately after the line where I try to set the texture and in the same code block, so I know for a fact that the allegedly texture setting line is being executed. There are no errors or warnings, but the textures on the sprites simply don't change. If anyone has any ideas for things to check or needs any additional information, I'd be happy to hear them.

Welcome to the forums @Asmun!

Could you share the code you are using? Also, what version of Godot are you using?

Changing the sprite in code should work using something like this:

var new_texture = preload("res://path_to_texture_here.png")
func _ready():
	get_node("sprite").texture = new_texture

But if it is not, then it may be something else is going on and that's causing it not to change.

a year later