Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

I need to trgger a remote event with desroy() but i have no idea how to do that?

Asked by 2 years ago

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!

01local gui = script:WaitForChild("ScreenGui")
02local plr = game.Players.LocalPlayer
03local SG = game.StarterGui
04 
05gui.Parent = plr.PlayerGui
06script.Parent:RemoveDefaultLoadingScreen()
07 
08repeat
09    wait(.5)
10until game:IsLoaded()
11wait(5)
12 
13gui.Frame:TweenPosition(UDim2.new(0, 0, -1.5, 0), Enum.EasingDirection.InOut,Enum.EasingStyle.Quad, 1)
14 
15wait(1)
View all 21 lines...
0
(you can see in the end that i got confused on what to do when i tried to fire the client Icy_limxz 14 — 2y
0
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 Shawnyg 4330 — 2y

1 answer

Log in to vote
1
Answered by 2 years ago

Hello,

What you can do is connect a function to a ChildRemoved Event and check if the instance you deleted was Gui or something else, you can achieve this by,

1local GuiParent = script.Parent.Parent
2local RemoteEvent = game.ReplicatedStorage.RemoteEvent
3 
4GuiParent.ChildRemoved:Connect(function(RemovedInstance)
5    if RemovedInstance.Name == "gui" then
6        RemoteEvent:FireServer()
7    end
8end)
Ad

Answer this question