The script actually works fine, the problem was that it would set a different height for the spot light, and i hadn't set a long enough cone for the spotlight. I'll leave the script here if anyone finds this useful, i did this so that the spotlight could be set as a player's child and it would remain above it even if the player rotates
extends SpotLight
export var height = 20
# Called when the node enters the scene tree for the first time.
func _ready():
set_physics_process(true)
set_as_toplevel(true)
func _physics_process(_delta):
var target = get_parent().get_global_transform().origin
#var pos = get_global_transform().origin
target.y = target.y+ height
set_global_position(self,target)
func set_global_position(spatialNode,vector3Position):
spatialNode.set_global_transform(Transform(spatialNode.get_global_transform().basis,vector3Position))