Roblox's variant of Lua, 'Luau', can use the `wait()` function.
This Lua 5.4 solution is similar to the previous solution, but I've included a simple but complete sample program to run it:
local user_input = ""
local q<const> = "q"
print("Press <q> to exit..")
while string.lower(user_input) ~= q do
io.write("> ")
user_input = io.read()
if user_input == "" then
else print ("> You wrote '".. user_input .."'")
end -- if
end -- while
print("> Goodbye!")
local clock = os.clock
function sleep(n)
local t0 = clock()
while clock() - t0 <= n do end
end
--
sleep(2) -- 2 second delay before closing program