Ive been looking around for a while this is my back up incase i dont find out how to work out this issue, What im trying to do is make a function when the gui gets destroyed, but i dont know how to do it, nor can i find any tutorial or page that can help with this specific situation, all efforts will be appreciated, thank you for taking your time to read this!
local gui = script:WaitForChild("ScreenGui")
local plr = game.Players.LocalPlayer
local SG = game.StarterGui
gui.Parent = plr.PlayerGui
script.Parent:RemoveDefaultLoadingScreen()
repeat
wait(.5)
until game:IsLoaded()
wait(5)
gui.Frame:TweenPosition(UDim2.new(0, 0, -1.5, 0), Enum.EasingDirection.InOut,Enum.EasingStyle.Quad, 1)
wait(1)
gui:Destroy()
gui.script = nil
game.ReplicatedStorage.Cutscene:FireClient()
end)

2 comments
(you can see in the end that i got confused on what to do when i tried to fire the client
Since this is already a local script, line 19 wouldn't make sense since you can't use :FireClient() when already on the client. It looks like you're making a custom loading screen? Check out this: https://developer.roblox.com/en-us/articles/Custom-Loading-Screens