Hello there. So I am using a big trusted edited version of Merely’s Soft Shutdown Script. It is from TheNexusAvenger, and it works until it is time to make the gui disappear which does not happen.
Here is the script he/she made:
local Players = game:GetService("Players")
local StarterGui = game:GetService("StarterGui")
local RunService = game:GetService("RunService")
local TeleportService = game:GetService("TeleportService")
--Set up teleport arrival.
TeleportService.LocalPlayerArrivedFromTeleport:Connect(function(Gui,Data)
if Data and Data.IsTemporaryServer then
--If it is a temporary server, keep showing the Gui, wait, then teleport back.
Gui.Parent = Players.LocalPlayer:WaitForChild("PlayerGui",10^99)
StarterGui:SetCore("TopbarEnabled",false)
StarterGui:SetCoreGuiEnabled("All",false)
wait(5)
TeleportService:Teleport(Data.PlaceId,Players.LocalPlayer,nil,Gui)
else
--If the player is arriving back from a temporary server, remove the Gui.
if Gui and Gui.Name == "SoftShutdownGui" then Gui:Destroy() end
end
end)
--Anything that can cause this to yeild will prevent teleport data being recieved.
local RenderStepped = RunService.RenderStepped
local StartShutdown = game.ReplicatedStorage:WaitForChild("StartShutdown")
local CreateTeleportScreen = require(script:WaitForChild("TeleportScreenCreator"))
--Set up event for when the server is shutting down.
StartShutdown.OnClientEvent:Connect(function()
--Create the Gui and have it semi-transparent for 1 second.
local Gui,Background = CreateTeleportScreen()
Background.BackgroundTransparency = 0.5
Gui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
wait(1)
--Tween the transparency to 0.
local Start = tick()
local Time = 0.5
while tick() - Start < Time do
local Dif = tick() - Start
local Ratio = Dif/Time
Background.BackgroundTransparency = 0.5 * (1 - Ratio)
RenderStepped:Wait()
end
Background.BackgroundTransparency = 0
end)
And I get this error, don’t know if it has anything to do with it:
Greetings, sometimes LocalScripts load up before the core gui so you need to make it wait until the gui arrives, here is the piece which should replace the errored line:
local currentTime = tick()
repeat wait() until tick() - currentTime > 5 or pcall(game.StarterGui.SetCore, game.StarterGui, "TopbarEnabled", false) end
Replace the line that’s erroring with that. It will repeat and not allow the script to go on until either 5 seconds have passed, or until CoreGui is fully loaded and SetCore() is able to be called.
local RunService = game:GetService("RunService")
local TeleportService = game:GetService("TeleportService")
--Set up teleport arrival.
TeleportService.LocalPlayerArrivedFromTeleport:Connect(function(Gui,Data)
if Data and Data.IsTemporaryServer then
--If it is a temporary server, keep showing the Gui, wait, then teleport back.
Gui.Parent = Players.LocalPlayer:WaitForChild("PlayerGui",10^99)
local currentTime = tick()
repeat wait() until tick() - currentTime > 5 or pcall(game.StarterGui.SetCore, game.StarterGui, "TopbarEnabled", false) end
StarterGui:SetCoreGuiEnabled("All",false)
wait(5)
TeleportService:Teleport(Data.PlaceId,Players.LocalPlayer,nil,Gui)
else
--If the player is arriving back from a temporary server, remove the Gui.
if Gui and Gui.Name == "SoftShutdownGui" then Gui:Destroy() end
end
end)
--Anything that can cause this to yeild will prevent teleport data being recieved.
local RenderStepped = RunService.RenderStepped
local StartShutdown = game.ReplicatedStorage:WaitForChild("StartShutdown")
local CreateTeleportScreen = require(script:WaitForChild("TeleportScreenCreator"))
--Set up event for when the server is shutting down.
StartShutdown.OnClientEvent:Connect(function()
--Create the Gui and have it semi-transparent for 1 second.
local Gui,Background = CreateTeleportScreen()
Background.BackgroundTransparency = 0.5
Gui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
wait(1)
--Tween the transparency to 0.
local Start = tick()
local Time = 0.5
while tick() - Start < Time do
local Dif = tick() - Start
local Ratio = Dif/Time
Background.BackgroundTransparency = 0.5 * (1 - Ratio)
RenderStepped:Wait()
end
Background.BackgroundTransparency = 0
end)
It now errors at : else
Thank you @Ponzimus , that solved this same problem for me I just realized having in our game.
Your code is perfect, just there is an extra unnecessary “end” at the end of it.
So it should be:
local currentTime = tick()
repeat wait() until tick() - currentTime > 5 or pcall(game.StarterGui.SetCore, game.StarterGui, "TopbarEnabled", false)