I have this script where its like a game timer and when it drops to 0 it ends the game but I was wondering If I should use tick() or wait
✓ ANSWER ACCEPTED
for a countdown script should I use tick or wait?
1 answer
✓ Accepted answer
You could make them both work, but I'd use os.time() or tick().
local start = os.time()
local gameLength = 10
local timeRemaining = gameLength
local timeElapsed = 0
local gameInSession = true
while gameInSession do
timeElapsed = os.time() - start
timeRemaining = gameLength - timeElapsed
if timeRemaining <= 0 then
gameInSession = false
end
wait()
end
-- while loop yields until its conditions are met or is broken
print("Game concluded")
This discussion is preserved as it was. New answers, comments, and votes are closed.
