Your code is hard to read because it's misformatted in the forums. However, the error is telling you that the object that you're calling rotate_x()
on (your head
reference) is not pointing to a valid object.
I see you got that reference with this code:
onready var head = $Head
That syntax is correct, but for it to work, your Head
object must be a direct child of the node containing the posted script. If it is not, that reference will fail and you'll end up with the error you reported.
Without seeing your scene tree, it's hard to say much more other than your Head
reference is currently null
.