+1 vote

From my understanding this is only an error when an areas collision is changed but I don't think I did that, at least not intentionally.

func player_damaged_screenclear():
var screen_clear = pl_damage_screenclear.instance()
get_tree().current_scene.add_child(screen_clear) 
    ^ the specific line that errors
screen_clear.global_position = hitbox.global_position
in Engine by (46 points)
edited by

2 Answers

0 votes
Best answer

I was able to figure it out myself. If I replaced:

get_tree().current_scene.add_child(screen_clear) 

with

get_tree().current_scene.call_deferred("add_child", screen_clear)
by (46 points)
+1 vote

As I understand it;
"gettree().currentscene.addchild(screenclear) "
where it says you want to add a node to your scene. If so, replace it with;

-If this script belongs to the stage root:

add_child(screen_clear)

-But if it belongs to a node one below the root:

get_parent().add_child(screen_clear)

I hope I have helped you. have a nice day.

by (95 points)

It didn't work unfortunately and it still gives the same error.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.