So, it looks like you're creating a new, independent instance of iteam_ma
in every frame with this code:
var madera1 = iteam_ma.instance()
I doubt that's what you intend to do here...
Next, you might add the current instance to the scene tree via a call to add_child()
- assuming the complex if
logic is all true in the current frame.
Finally, you might try to remove the current instance from the scene tree, if the Shif
action is pressed in the current frame...
I'd say what's likely happening is this:
In some frame...
- You create a new instance
- You add that instance to the tree
- The
Shif
action is not pressed, so you don't remove the instance from the tree
Now, in some future frame...
- You create a new instance
- You don't add it to the tree (because your
if
checks aren't true)
- You attempt to remove that instance from the tree (because
Shif
if pressed)
Since that instance was never added to the tree, it cannot be removed from the tree, and will lead to the error you reported...