I made a script that teleports players to a private server. Once the Countdown reaches 0, it will teleport a table of the players to the server. When this happens, sometimes the server will crash. Anybody know why? Here's the script
local ts = game:GetService("TeleportService") local summerevent = game.ReplicatedStorage.SummerEvent local countdown = false summerevent.JoinGame.OnServerEvent:Connect(function(plr, playerslot) playerslot.Value = plr.Name end) summerevent.LeaveGame.OnServerEvent:Connect(function(plr, playerslot) playerslot.Value = "None" end) while true do --main part wait(1) if summerevent.Countdown.Value ~= 0 then summerevent.Countdown.Value = summerevent.Countdown.Value - 1 else summerevent.Countdown.Value = 25 local code = ts:ReserveServer(5608381405) local players = {game.Players:FindFirstChild(summerevent.Players.Player1.Value),game.Players:FindFirstChild(summerevent.Players.Player2.Value),game.Players:FindFirstChild(summerevent.Players.Player3.Value),game.Players:FindFirstChild(summerevent.Players.Player4.Value)} ts:TeleportToPrivateServer(5608381405,code,players) for i,v in pairs(summerevent.Players:GetChildren()) do v.Value = "None" end end end
Try teleporting the players to your private server using wait(), as if 10 players join a server in a same time, its high possibility to get a huge amount of server lag. And try making it the spawn function, so that the timer won't wait() you will be adding.
Lemme know if it helps!