Help with soft shutdown?

I need help i am trying to write a soft shutdown that makes a menu visible and animates it

is based off of this one

code:

local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")

local function OpenRebootScreen(plr)
	--L1 pos/size: 0.487, 0, 0.475, 0 / 0.974, 0, 0.029, 0
	--L2 pos/size: 0.476, 0, 0.516, 0 / 0.953, 0, 0.029, 0
	--slc text size: 0.324, 0, 0.148, 0
	--main text: All SLC servers are restarting for update(s). Please standby.
	local RebootScreen = plr:WaitForChild("PlayerGui", 2).RebootScreen
	local ModuleService = require(game:GetService("ReplicatedStorage"):WaitForChild("ModuleService", 2))

	local cont = RebootScreen.Container
	local L1 = RebootScreen.Container.line_1
	local L2 = RebootScreen.Container.line_2
	local slc = RebootScreen.Container.slc_text
	local main = RebootScreen.Container.main_text

	local Tween = function(...)
		return script.Tween.Tween(...)
	end

	cont.Visible = true

	Tween(cont, 1, "Exponential", "Out", {Position = UDim2.new(0.5, 0, 0.5, 0)})
	Tween(L1, 2, "Exponential", "Out", {Position = UDim2.new(0.487, 0, 0.475, 0)})
	task.wait(1)
	Tween(L2, 2, "Exponential", "Out", {Position = UDim2.new(0.476, 0, 0.516, 0)})
	task.wait(2)
	Tween(slc, 2, "Exponential", "Out", {Size = UDim2.new(0.324, 0, 0.148, 0)})
	ModuleService:write(main, "All SLC servers are restarting for update(s). Please standby.")
end

if (game.VIPServerId ~= "" and game.VIPServerOwnerId == 0) then
	-- this is a reserved server without a VIP server owner
	local waitTime = 5

	Players.PlayerAdded:connect(function(player)
		OpenRebootScreen(player)
		task.wait(waitTime)
		waitTime = waitTime / 2
		TeleportService:Teleport(game.PlaceId, player)
	end)

	for _,player in pairs(Players:GetPlayers()) do
		OpenRebootScreen(player)
		TeleportService:Teleport(game.PlaceId, player)
		task.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

		task.wait(1)
		local reservedServerCode = TeleportService:ReserveServer(game.PlaceId)

		for _,player in pairs(Players:GetPlayers()) do
			OpenRebootScreen(player)
			task.wait(4)
			TeleportService:TeleportToPrivateServer(game.PlaceId, reservedServerCode, { player })
		end

		Players.PlayerAdded:connect(function(player)
			OpenRebootScreen(player)
			task.wait(4)
			TeleportService:TeleportToPrivateServer(game.PlaceId, reservedServerCode, { player })
		end)

		while (#Players:GetPlayers() > 0) do
			task.wait(1)
		end
	end)
end

it doesnt work at all , it doesnt show the menu or tp me to a reserved place or show errors.Can someone help ?

ok hooman on the devforum, let’s fix this. :robot:

let’s start with replacing ur current script with this to debug.

print("Script is starting")

local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")

local function OpenRebootScreen(plr)
    print("OpenRebootScreen function called for player: ", plr.Name)
    local PlayerGui = plr:WaitForChild("PlayerGui", 2)
    assert(PlayerGui, "PlayerGui not found for player: " .. plr.Name)
    local RebootScreen = PlayerGui.RebootScreen
    assert(RebootScreen, "RebootScreen not found in PlayerGui for player: " .. plr.Name)

    local ModuleService = require(game:GetService("ReplicatedStorage"):WaitForChild("ModuleService", 2))
    assert(ModuleService, "ModuleService not found")

    local cont = RebootScreen.Container
    local L1 = RebootScreen.Container.line_1
    local L2 = RebootScreen.Container.line_2
    local slc = RebootScreen.Container.slc_text
    local main = RebootScreen.Container.main_text

    assert(cont and L1 and L2 and slc and main, "One or more GUI elements not found")

    local Tween = function(...)
        return script.Tween.Tween(...)
    end

    cont.Visible = true

    Tween(cont, 1, "Exponential", "Out", {Position = UDim2.new(0.5, 0, 0.5, 0)})
    Tween(L1, 2, "Exponential", "Out", {Position = UDim2.new(0.487, 0, 0.475, 0)})
    task.wait(1)
    Tween(L2, 2, "Exponential", "Out", {Position = UDim2.new(0.476, 0, 0.516, 0)})
    task.wait(2)
    Tween(slc, 2, "Exponential", "Out", {Size = UDim2.new(0.324, 0, 0.148, 0)})
    ModuleService:write(main, "All SLC servers are restarting for update(s). Please standby.")
end

if (game.VIPServerId ~= "" and game.VIPServerOwnerId == 0) then
    print("Teleporting players in VIP server")
    local waitTime = 5

    Players.PlayerAdded:connect(function(player)
        OpenRebootScreen(player)
        task.wait(waitTime)
        waitTime = waitTime / 2
        TeleportService:Teleport(game.PlaceId, player)
    end)

    for _,player in pairs(Players:GetPlayers()) do
        OpenRebootScreen(player)
        TeleportService:Teleport(game.PlaceId, player)
        task.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

        task.wait(1)
        local reservedServerCode = TeleportService:ReserveServer(game.PlaceId)
        assert(reservedServerCode, "Failed to reserve server")

        for _,player in pairs(Players:GetPlayers()) do
            OpenRebootScreen(player)
            task.wait(4)
            TeleportService:TeleportToPrivateServer(game.PlaceId, reservedServerCode, { player })
        end

        Players.PlayerAdded:connect(function(player)
            OpenRebootScreen(player)
            task.wait(4)
            TeleportService:TeleportToPrivateServer(game.PlaceId, reservedServerCode, { player })
        end)

        while (#Players:GetPlayers() > 0) do
            task.wait(1)
        end
    end)
end

print("Script has finished running")

I made this really quickly, so it’s not the best way to debug, note that. Anyways, see if this works or not.

1 Like

Will try this in about a hour or two when i get on sorry for late response had to go to bed.