Problem With Soft Shutdown Not Working

So I have been working on a game and finally decided to add a soft shutdown. I added one that when I shutdown the server, it shows a GUI and then rejoins the player automatically. To my surprise, it didn’t work. I am not a scripter but it was from a youtube tutorial and it worked for the person who made it.

I’ll add the script right here:

local TeleportService = game:GetService(“TeleportService”)
local players = game:GetService(“Players”)
local Shutdown = script:WaitForChild(“Shutdown”)
local Closing = false
local GameId = 6494529462 – put Game ID here

game.OnClose = function()
print(‘[Game]//Close’)

spawn(function()
	for i,v in pairs(players:GetChildren()) do
		pcall(function()
			Shutdown:Clone().Parent = v:WaitForChild("PlayerGui")
			wait(5)
			TeleportService:Teleport(GameId, v)
		end)
	end
end)

local offlineMode = game.JobId == ""
if offlineMode then
	print("[Game]//Offline Mode")
else
	wait(5)
end

end

Please tell me if anything is wrong with it!

I’m not sure what the difference could be, but couldn’t you use the BindToClose() function instead? It’d look something like this:

local TeleportService = game:GetService("TeleportService")
local players = game:GetService("Players")
local Shutdown = script:WaitForChild("Shutdown")
local Closing = false
local GameId = 6494529462 – put Game ID here

game:BindToClose(function()
    print("[Game]//Close")

    spawn(function()
	    for i,v in pairs(players:GetChildren()) do
		    pcall(function()
			    Shutdown:Clone().Parent = v:WaitForChild("PlayerGui")
			    wait(5)
			    TeleportService:Teleport(GameId, v)
		    end)
	    end
    end)

    local offlineMode = game.JobId == ""

    if offlineMode then
	    print("[Game]//Offline Mode")
    else
	     wait(5)
    end
end)

I will test this script out and hopefully it works, Thanks!

Np, also if your max-player count is above 6, I’d recommend decreasing the amount of time since BindToClose can go up to a max of 30 seconds before shutting down

Hmm, your script didn’t work oddly. I’m going to try it on a baseplate to see if maybe it was just that game.

Instead of the system automatically rejoining the players, it showed “The games developer has temporarily shut down the server. Please try again.” I don’t know what could have happened there… I’m going to further explain what I said above as I could have explained it incorrectly. Basically what I’m trying to do is something like Adopt Me’s soft shutdown where it shows a message, then has the system do a client-based teleport into said game. For me, it would be the same game.

I don’t even know what Adopt Me does Did you put the script in ServerScriptService? It should be inside there

I think you may also need to use ReserveServer to create a separate place that’ll give you time before you get teleported back?

Not sure if you already watched this tutorial, but if you haven’t I highly recommend it. It explains some of the services required and is what I built my soft shutdown system off of.

1 Like

Basically what Adopt Me! does is they shut down the servers, then at the bottom of the screen they have a GUI that says something like “Shutting Down Servers”. After that the system takes everyone and puts them in a fresh server with the new update.

Thank you so much! I will definitely be trying this out and even making my own version. Like I said to Jackscarlett, I want to have a soft shutdown like adopt me. I have tried to make one before but I am not a scripter so it didn’t work… But this will be helpful for me to learn all of the services!

I’m so glad I could help! Goo dluck on your game! :smiley: