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??
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"