This is a script for a new game that i'm working on. It starts to check for players whenever two or more players enter the game, then the timer starts running. The problem is that whenever the timer hits zero, the enterplr function restarts. what seems to be the problem?
Data = game.Workspace.GameData
TimeLeft = game.Workspace.GameData.Timer
Players = game.Players
Plr_amnt = Data.Plrs
function enter(plr)
wait()
Plr_amnt.Value = Players.NumPlayers
end
function check()
wait(2)
if Plr_amnt.Value >= 1 then
gamestart()
elseif Plr_amnt.Value == 1 then
print("Retrying...")
wait(2)
check()
end
end
function gamestart()
TimeLeft.Value = 50
for i=1,50 do
wait(1)
TimeLeft.Value = TimeLeft.Value - 1
end
end
while wait(enter()) do
check()
end
game.Players.PlayerAdded:connect(enter)

1 comment
GameData is a folder and TimeLeft, Plr_amount are numvalues