Hey. I scripted my small soft shutdown script but the problem is: the BindToClose function won’ work good. I mean with that, the UI is like getting enabled but not even a milisecond after this, I get disconnected as the developer have shutted the server down. My small code is:
if not RunService:IsStudio() then
game:BindToClose(function()
wait(2)
local reservedServer = tpServer:ReserveServer(game.PlaceId)
for i,v in pairs(game.Players:GetPlayers()) do
if v:FindFirstChild("PlayerGui") then
v.PlayerGui.Shutdown.Enabled = true
v.PlayerGui.Shutdown.ShutdownServer.Visible = true
tpServer:TeleportToPrivateServer(game.PlaceId,reservedServer,v)
end
end
end)
end
Video how it looks like:
I would appreciate it greatly if someone could help me at this problem. xd
if u are using the shutdown all servers button from the site, this script wont work. I recommend making some sort of Version checker rather than making it manual. If the version is different from the current one then just move all the player to the new server.
hmmm Im not really sure. Maybe if u somehow queue the players wait for the shutdown to happen and then teleport them to the game. That can happen using other game for teleporting
Have you ever scripted? BindToClose is saying the game: Wait before shutting down and kicking all players. It’s doing that but somehow the game is still kicking everyone after a second.
Well I see the issue, “TeleportToPrivateServer()” needs to be passed an array of player instances not individual player instances.
Something like this.
if not RunService:IsStudio() then
game:BindToClose(function()
local reservedServer = tpServer:ReserveServer(game.PlaceId)
tpServer:TeleportToPrivateServer(game.PlaceId, reservedServer, game.Players:GetPlayers())
end)
end
I’d recommend utilizing game.JobId first, then use game:BindToClose. Something like this:
if not RunService:IsStudio() then
local reservedServer = tpServer:ReserveServer(game.PlaceId)
if game.JobId == "" then
task.wait(2)
for i,v in pairs(game.Players:GetPlayers()) do
if v:FindFirstChild("PlayerGui") then
v.PlayerGui.Shutdown.Enabled = true
v.PlayerGui.Shutdown.ShutdownServer.Visible = true
tpServer:TeleportToPrivateServer(game.PlaceId,reservedServer,v)
end
end
game:BindToClose(function()
if #game.Players:GetPlayers() > 0 then
for Index, Player in ipairs(game.Players:GetPlayers()) do
v.PlayerGui.Shutdown.Enabled = true
v.PlayerGui.Shutdown.ShutdownServer.Visible = true
tpServer:TeleportToPrivateServer(game.PlaceId,reservedServer,v)
end
end
end)
end
end
I believe this would work, let me know if I did anything wrong!
Nw! I think your script would work too but I used the method stated above but still thank you for your work and time into this script! Thank you so much. <3