hi, i maked minimal shutdown script but script not working on game have more than 1 players.
local teleportService = game:GetService("TeleportService")
game:BindToClose(function()
task.wait(1)
game.ReplicatedStorage.Shutdown:FireAllClients() --for shutdown gui.
teleportService:TeleportAsync(game.PlaceId, game.Players:GetPlayers())
while game.Players:GetPlayers()[1] do
task.wait(1)
end
end)
It’s possible that game.Players:GetPlayers() runs once, causing what @neweve2323 mentioned. Try rewriting the loop in the following way to check if that’s the case:
while task.wait(1) do
if #game.Players:GetPlayers() == 0 then break end
end