Skip to content
← Back to Community
How do I do a wait() / delay() .. (LUA)
Profile icon
kittymanandcat

Roblox had this thing called "wait()" where you can make a wait before the script moves on, but I noticed that there is no wait() on repl.it, it is set to lua, so i don't know, is there something I can use to delay a code?

Answered by InvisibleOne [earned 5 cycles]
View Answer
Voters
Profile icon
KrazyKKStar
Profile icon
kittymanandcat
Comments
hotnewtop
Profile icon
InvisibleOne

Here

function wait(seconds) local start = os.time() repeat until os.time() > start + seconds end
Profile icon
kittymanandcat

@InvisibleOne
Thank you, and I learned that I can make a working time thing by:
while true do
script.Parent.Text = "The date is: "..os.date()
wait(0.1)
end

Profile icon
Antelear

you can just..

local wait = require("socket").sleep wait(1) print("")

but for some reason it doesn't work for me anymore, so might have to find out why it might not work for you too. but yeah, hope this helps

Profile icon
RYANTADIPARTHI

Maybe try this:

function sleep(n) os.execute("sleep " .. tonumber(n)) end

here's a link for more info:

https://stackoverflow.com/questions/17987618/how-to-add-a-sleep-or-wait-to-my-lua-script

Profile icon
kittymanandcat

@RYANTADIPARTHI
I will try it!