Actually, I wasn't sure there was going to be a problem or not myself, and really, if you noticed, it didn't stop the execution of the program. It just ran a cycle or two and then it was available. In general, it's good practice to initialize in the ready function. Just get in the habit of it for anything outside var x = 20. If you are making a call to any object's variable or function, it's better to initialize in the ready function or use onready. It's all these scripts and you don't know the order they are going to be assembled. The ready function or the onready call is the best way to go. The weird thing here is it was a property of the same node that the script was on, so it doesn't seem like there would be a problem, but apparently so.

It's quite confusing for me. But I have encountered a similar error like this before, but I don't know how to fix it. Now thanks to your guidance, I know how to fix it. Every time I set the variable var x = global_position, I get an "transform" error that I want to break the computer because I don't know how to fix it.Simply add "onready" hihi . Once again thank you very much, Mr Fire7Side!

@Odin said: It's quite confusing for me. But I have encountered a similar error like this before, but I don't know how to fix it. Now thanks to your guidance, I know how to fix it. Every time I set the variable var x = global_position, I get an "transform" error that I want to break the computer because I don't know how to fix it.Simply add "onready" hihi . Once again thank you very much, Mr Fire7Side!

You are welcome. Glad I could help.

8 months later