Hello, as of again, the title says it all, i want to know how can i improve merely’s soft shutdown script, i done some things, but it changed almost nothing, so i would like help with this.(Sorry for the randomness, and here is merely’s soft shutdown script: https://devforum.roblox.com/t/soft-shutdown-script/47588/https://github.com/MerelyRBLX/ROBLOX-Lua/blob/master/SoftShutdown.lua )
Here are the “improvements”:
--[[
SoftShutdown 1.2
Author: Merely
Edited by PhoenixRessusection
This system lets you shut down servers without losing a bunch of players.
When game.OnClose is called, the script teleports everyone in the server
into a reserved server.
When the reserved servers start up, they wait a few seconds, and then
send everyone back into the main place.
I added wait() in a couple of places because if you don't, everyone will spawn into
their own servers with only 1 player.
--]]
local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")
if (game.VIPServerId ~= "" and game.VIPServerOwnerId == 0) then
-- this is a reserved server without a VIP server owner
local TempMsg = Instance.new("Message")
TempMsg.Text = "This is a temporary lobby. Teleporting back in a moment."
TempMsg.Parent = workspace
local waitTime = 5
Players.PlayerAdded:Connect(function(plr)
wait(waitTime)
waitTime = waitTime / 2
TeleportService:Teleport(game.PlaceId, plr)
end)
for _, plr in ipairs(Players:GetPlayers()) do
TeleportService:Teleport(game.PlaceId, plr)
wait(waitTime)
waitTime = waitTime / 2
end
else
game:BindToClose(function()
if (#Players:GetPlayers() == 0) then
return
end
if (game:GetService("RunService"):IsStudio()) then
return
end
local TempMsg = Instance.new("Message")
TempMsg.Text = "Rebooting servers for update. Please wait"
TempMsg.Parent = workspace
wait(2)
local reservedServerCode = TeleportService:ReserveServer(game.PlaceId)
for _, plr in ipairs(Players:GetPlayers()) do
TeleportService:TeleportToPrivateServer(game.PlaceId, reservedServerCode, { plr })
end
Players.PlayerAdded:Connect(function(plr)
TeleportService:TeleportToPrivateServer(game.PlaceId, reservedServerCode, { plr })
end)
while (#Players:GetPlayers() > 0) do
wait(1)
end
-- done
end)
end