get_node("/root/Node2D/Timer").set_wait_time(5)
				get_node("/root/Node2D/Timer").start()
				stopsalto()

it should stop the last function (stopsalto) of running until 5 seconds had passed but the function runs without waiting.

i am learning, please be nice.

you can send a timeout signal from the inspector, I think it is more reliable.

it should look something like this in the code

    you have to use the timeout signal or await
    ... in your case, i think you can use SceneTreeTimer with await

    await stops execution of the script until the signal has fired

    await get_tree().create_timer(5.0).timeout
    stopsalto()
    • Starting a timer will not stop your code from running. It will only make the timer start counting down.
    • Nothing actually stops, everything runs, including your timer.
    • So what is happening is, the timer starts, the function gets called almost immediately after that, stuff keep on happening for the next 5 seconds as nothing stops, and then the timer finishes counting down.
    • Think of it this way, you will do "something" when the timer finishes. Not stop code execution for 5 seconds and then do this "something".
    • How to do this "something" then? You connect the timeout signal of the Timer node to a function.
    • This function will do this "something".
    • The how is shown in el_malo 's post.
    • This way, timer starts, the code doesn't stop, after 5 seconds the timer finishes counting down, and emits a signal called timeout, the function connected to this Timer's timeout signal will be called and execute whatever code inside it.
    • Hope the explanation helped you understand why your code didn't behave as you expected.

    You have to set a timeout function. Timer doesn't do anything but call another function (the timeout callback).

    thanks this problem is fixed.
    sending a signal has been succesful.