Help with opening gui on game shutdown

I am trying to have a gui tween in and the topbar hidden when I shut down the game from the website.
I have a very small amount of lua knowledge so I have no idea why it isn’t working.

This is my code. It is in a localscript in serverscriptservice.

Restartframe = game.StarterGui.SoftRebootGUI

    game:BindToClose(function()
		local starterGui = game:GetService('StarterGui')
	starterGui:SetCore("TopbarEnabled", false)
Restartframe.Frame:TweenPosition(UDim2.new(0,0,-0.1,0), "InOut", "Sine", 0.5)
    end)

local scripts do not work in serverscriptservice serverscriptservice has server in it so only server scripts can run there here is a fix to your code remember to use remote events when u want to show a gui and also we use playergui not StarterGui here

server script inside serverscriptservice:

game:BindToClose(function()

for _,plr in pairs(game.Players:GetPlayers()) do

game.ReplicatedStorage.RemoteEvent:FireClient(plr)

end

wait(30)

end)

ReplicatedStorage:
image

local script inside starterGui:

game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function()

local starterGui = game:GetService('StarterGui')

starterGui:SetCore("TopbarEnabled", false)

local Restartframe = script.Parent.SoftRebootGUI

Restartframe.Frame:TweenPosition(UDim2.new(0,0,-0.1,0), "InOut", "Sine", 0.5)

end)

hope this helps :slight_smile:

3 Likes

Ok imma try that. (30 charsssssssssssss)

Works perfectly! Thanks so much!

1 Like