Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Why repeat wait() until is not working???

Asked by 5 years ago
Edited 5 years ago

I make a mini game script that if have no players in the mini game, the timer stops and the message says "Time ended". But why its not working. I have a folder named "Ingame". The parent of this folder is workspace. It is working when the timer is 0 then it says times up but when the ingame is nil it not working and it is continued to countdown until it reaches 0 and disables the script of the timer. This is the part of my script that i mean.

local Time = game.ReplicatedStorage.Values:WaitForChild("Timer")
repeat
game.ServerScriptService.Time.TimeThreeMinutes.Disabled = false
wait()
until Time.Value == "0:00" or workspace.Ingame == nil
game.ServerScriptService.Time.TimeMinutes.Disabled = true
Status.Value = "Time's up"

Can you help me??

0
Time.Value == "0:00", does that not seem a bit STRANGE greatneil80 2647 — 5y
0
i mean i missed the variables robloxsario 76 — 5y
0
there edited robloxsario 76 — 5y
0
greatneil80 i think its supposed to be a string value that copies another value and translates it into time pixploxboxblox -2 — 5y
0
No ^ DeceptiveCaster 3761 — 5y

1 answer

Log in to vote
0
Answered by
sleazel 1287 Moderation Voter
5 years ago

To check if a object exist, you actually should check its parent, due to way roblox removes objects - Ingame.Parent == nil The problem is that you are probably want to check number of children in that folder instead and not if the folder exists, cause that makes no sense. You can do it like this:

local Time = game.ReplicatedStorage.Values:WaitForChild("Timer")
repeat
game.ServerScriptService.Time.TimeThreeMinutes.Disabled = false
local children = workspace.Ingame:GetChildren()
wait()
until Time.Value == "0:00" or #children == 0
game.ServerScriptService.Time.TimeMinutes.Disabled = true
Status.Value = "Time's up"
Ad

Answer this question