Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

using delay() wont wait 1 second after the first time?

Asked by 4 years ago
while true do
    wait()
print("fast print")
delay(1,function()
    print("slow print")
end)
end

I have a simple setup for delay. I want "fast print" to print as fast as the while true do loop and also have "slow print" only print every one second.

when the game runs slow print only waits once then it prints as fast as the fast print.

am I doing something wrong?

1 answer

Log in to vote
1
Answered by
SmartNode 383 Moderation Voter
4 years ago
Edited 4 years ago

Here's a wiki on when delay() was added.

Basically,

delay() == spawn() + wait()

So technically,

delay(1, function() print("slow print") end) is spawn(function() wait(1) print("slow print") end)

Delay doesn't yield the script so like execution time is not paused when doing delay() A better option would just put wait(1) before print('slow print')

Ad

Answer this question