Hi. Simple question, how do I wait for a function to return something and then run code when it does?
I just have a simple timer function that counts down from whatever the second argument is (like 30 seconds). When it reaches 0, I want it to return that it reached 0 so that the script can do a certain thing.
local function HurryUpNoob(running, seconds)
while wait(1) do
if running == true then
if seconds < 1 then
running = false
return "Time exceeded"
end
seconds = seconds - 1
Request.Countdown.Text = seconds
else break end
end
end
EventFolder.KeypadClick.OnClientEvent:Connect(function()
local hh = true
local grogg = 30
HurryUpNoob(hh, grogg)
-- i think it would go somewhere here
Frame.Visible = true
end)
Mate, this is Lua, not C# or JavaScript/TypeScript. Async and await doesn’t exist here. All functions are syncronised by default and will yield the code until the code inside function finishes running.
Your code will execute synchronously so you simply put whatever you want in the place of your comment in the code and it will run after the function returns.