- Edited
After updating from Godot 3 to 4, the error "Identifier "global_position" not declared in the current scope" has appeared. I'm not sure why this is, as I have been unable to find any references or resources online which show this as one of the changes between 3 and 4. Admittedly, I'm fairly new to Godot and programming in general, so maybe it's a fairly obvious solution, I don't know.
Anyways, here is what is causing the error:
func spawn_effect(effect: PackedScene, effect_position: Vector2 = global_position):
if effect:
var EFFECT = effect.instantiate()
get_tree().current_scene.add_child(EFFECT)
EFFECT.global_position = effect_position
return EFFECT