Can't change variable

Godot Version

4.2.2

Question

Im making a checkpoint system for my game and when I try to change the variable for the position it stays at 0,0

here is the code

func _on_checkpoint_body_entered(body):
	var checkpointX = 2419
	var checkpointY = 500
and

func kill():
	self.position = Vector2(checkpointX, checkpointY)

when starting with var it makes a new variable; you might see a warning about “shadowing” this is when you create a new variable that has the same name as an existing one, but this new variable is in a lower “scope”. You are only editing the lower scope variable, try removing the var within this function.

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.