Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

1 comment

0

A) ChildRemoving B) compare it to nil

1 answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.