Hello, I have been working on a minigame script, and the game seems to work perfectly, but when enough people are playing it freezes at this part on the script randomly.
To summarize: The script can work with 20 people, but after awhile it randomly breaks displaying one of those texts as hints.
I'm not sure if it freezes because a player leaves the game or what. Can someone help me put a check in the script to prevent it from breaking? Any help would be really appreciate!
while cc < 2 do
cc = 0
c = game.Players:GetChildren()
for num, obj in pairs(c) do
if obj:FindFirstChild("Playing") then
if obj.Playing.Value then
cc = cc + 1
end
end
end
h.Text = "Need at least 2 players to begin games"
wait(1)
end
h.Text = "New round will begin soon..."
wait(3)
h.Text = "Choosing random game..."
wait(3)
m = game.Lighting.Minigames:GetChildren()
mg = m[math.random(1,#m)]
map = mg.Map
set_spawns(map)
map.Parent = game.Workspace
h.Text = (""..mg.Name)
wait(5)
h.Text = "Get ready to fight..."
wait(2)
c = game.Players:GetChildren()