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

How can I detect if a GUI get's removed after it's been added?

Asked by 4 years ago

Sorry if the title is confusing

while true do 
    wait(.6)





for i, v in pairs(game.Players:GetPlayers()) do
    if (v.Character.HumanoidRootPart.Position - new.Position).magnitude <= (35) then
        if v.Character:FindFirstChild("Mask")or  v.Character.Humanoid.Health == 0  then


            else 

    if v.PlayerGui:FindFirstChild("FlashGUI") then
        else
        local newclone = clone:Clone()
        newclone.Parent = v.PlayerGui
        newclone.pos.Value = new.Position
        newclone.LocalScript.Disabled = false
        newclone.me.Disabled = false
            end
            end
             end
    end


end

This is my code it works but if the flashgui gets destroyed it wont get added back

0
A) ChildRemoving B) compare it to nil DeceptiveCaster 3761 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

To detect when a GUI is removed from a player's PlayerGui put a LocalScript in StarterPlayer >> StarterPlayerScripts and write this code in it:

local player = game.Players.LocalPlayer
local playerGui = player.PlayerGui -- Player Gui is where all GUIs go from StarterGui.

playerGui.ChildRemoved:Connect(function(object)
    if object.Name == "GuiName" then
        -- Do something.
    end
end)

-- The 'object' argument referring to the instance that is being removed.
Ad

Answer this question