We instead check constantly, but keep track of how much time has passed. Here's two ways to do it:
local start = tick();
while tick() - start > 18000 and not over do
wait(1);
end
local time = 0;
while time < 18000 and not over do
time = time + wait(1);
end
(The wait time is of course changeable; just however quickly you want / need it to respond to the changing of whatever overcondition you have)
EDIT:
OR, we can intentionally have two threads race to do something first. I don't think this is a very good idea for several reasons, but it will work, most of the time, I think. It would require a little different set up, but may or may not be more elegant if a specific (ROBLOX instance) event triggers the end of the match:
local matchIdentifier = {};
function StopMatch(cause)
end
function endMatchIn(time,matchid)
delay(function()
if matchIdentifier == matchid then
StopMatch("time");
end
end, time);
end
function StartMatch()
matchIdentifier = {};
endMatchIn(18000,matchIdentifier);
end
game.Players.PlayerAdded:connect(function()
StopMatch("join");
end);
(I do not think this is a good approach at all, but it will work)
2 comments
Aww, you did implement my idea in an edit. By the way, pretty sure delay first argument must be a number.
So, lets say in my game, either a value turns true or 18000 seconds pass. Where would I put the "if game.Workspace.Value.Value==true then" or whatever