Error, my game keeps crashing for no reason

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Wurzelpilz

I broke Godot and I don’t wanna restart the whole project :frowning: It worked ten minutes ago, I renamed Sprite to Player Sprite and forgot to change it in my script, crash of course, so I changed it in my script, still crash, I reversed everything as it was before and it’s still crashing

	if velocity.y < 0 and not is_on_floor():
	$Sprite.play("Jump")
elif velocity.y > 0 and not is_on_floor():
	$Sprite.play("Fall")

Breakpoint at this line: $Sprite.play(“Fall”) since Sprite is no longer found. :expressionless:

enter image description here

Hi,
godot chrashes? or throws an error?
What does the error say?

klaas | 2021-07-24 20:10

I added an Image to my post, my game crashes not Godot…since it can’t find the sprite, deleted all my sprites, created a new AnimatedSprite still crash.

Wurzelpilz | 2021-07-24 20:25

can you post the error that has been thrown?
Look into errors!

klaas | 2021-07-24 20:27

When you type into the editor a string with $ the editor should give you a list of available objects in the tree. When the object you are refeering to isnt present in the tree the editor will give an error into the console while evaluating your script. Since that does not happen (i guess) the $Sprite you are refeering to must be present in the editor but not on runtime.

klaas | 2021-07-24 20:33

When I type $ in my editor, Sprite is available. What you see on my image is done via auto complete. I don’t get an error at all, only this Breakpoint and game freeze,

Wurzelpilz | 2021-07-24 20:41

That is strange … it literally says there is a breakpoint. But i see no breakpoint statement in your code.
Have you closed godot and reopened the project?

Do you have another Script with the name Player.gd?

klaas | 2021-07-24 20:47

No, only this player, already restarted, even deleted the whole animation sprite and redone everything. Still doesn’t work anymore.

Wurzelpilz | 2021-07-24 20:50

I dont think the problem comes from $Sprite its more likely its this Player.gd script.
Copy the source of Player, delete the script.
Then create a new script on the Player and paste in your code.
Maybe its some weird script caching going on.

klaas | 2021-07-24 20:54

Okay I copied the content of my script, deleted the entire script file from my project, created a new one, pasted and it works now, finally. Thank you,

Wurzelpilz | 2021-07-24 21:00

:bust_in_silhouette: Reply From: Wurzelpilz

Solution: I copied the content of my script, deleted the entire script file from my project, created a new one, pasted and it works now, Thank you, Klaas!

The reason why this worked is because there was a break point. To remove a break point is by clicking on it, but deleting a script and making it again would also remove it.

Eilrahc | 2023-03-16 02:39