Using get_script() to call another node not working

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

I am having trouble calling a function from one Node into another. This is the code to call a player clock in a chess game:

print("pausing")
var clock = get_tree().get_root().get_node("Chess/PlayerClock")
clock.get_script().pause_clock()
print("paused")

This is the code in the clock Node

extends Label

func pause_clock():
    print("CLOCK PAUSED!")

The output is simply:

pausing
paused

I also tried

clock.get_scipt().call("pause_clock")

With the same result. Does anyone know why the function is not called?

Steve

:bust_in_silhouette: Reply From: volzhs

you don’t need to call additional get_script()
just try clock.pause_clock()