until roundLength == 0 or canWin == false or #workspace.InGame:GetChildren() == 0 for i = 1, #players do if players[i].Character ~= nil then players[i].Character.Parent = workspace wait(10) map:Destroy() if workspace.InGame:GetChildren() == 0 then local Part = game.Workspace.MainSpawn local Stops = game.Workspace.Sounds.InLevel:GetChildren() for _, v in pairs (EndParts) do Part.Touched:Connect(function(hit) local humanoid = hit.Parent:FindFirstChild("Humanoid") if humanoid then game.Lighting.ClockTime = 14 for _, music in pairs (Stops) do music:Stop() end humanoid.WalkSpeed = 16 v.Transparency = 0 v.CanCollide = true end end) end end end end end
basically, when you're in a round in the game you get put into an InGame folder in workspace, and when you're out of the round the parent of the character is workspace again, everything I just said works but why won't it execute the script under the if statement? If more of the script is needed I can provide it, however, it's very long.
Hello.
Solution:
To get the number of items in a table, you must put a hashtag (#) before the table.
Fixed Code:
until roundLength == 0 or canWin == false or #workspace.InGame:GetChildren() == 0 for i = 1, #players do if players[i].Character ~= nil then players[i].Character.Parent = workspace wait(10) map:Destroy() if #workspace.InGame:GetChildren() == 0 then local Part = game.Workspace.MainSpawn local Stops = game.Workspace.Sounds.InLevel:GetChildren() for _, v in pairs (EndParts) do Part.Touched:Connect(function(hit) local humanoid = hit.Parent:FindFirstChild("Humanoid") if humanoid then game.Lighting.ClockTime = 14 for _, music in pairs (Stops) do music:Stop() end humanoid.WalkSpeed = 16 v.Transparency = 0 v.CanCollide = true end end) end end end end end
Im pretty sure you need to put the condition next to the if statement like this ~~~~~~~~~~~~~~~~~ if workspace.InGame:GetChildren() == 0then
local Part = game.Workspace.MainSpawn local Stops = game.Workspace.Sounds.InLevel:GetChildren() for _, v in pairs (EndParts) do Part.Touched:Connect(function(hit) local humanoid = hit.Parent:FindFirstChild("Humanoid") if humanoid then game.Lighting.ClockTime = 14 for _, music in pairs (Stops) do music:Stop() end humanoid.WalkSpeed = 16 v.Transparency = 0 v.CanCollide = true end end) end end end end
end
~~~~~~~~~~~~~~~~~