How to know if a gui was destroyed?

Hello everyone. I’m trying to make a script that kicks the player if it somehow deletes a gui from his PlayerGui.
I have tried several ways, but I can’t make it work.
Any suggestions?

Thanks in advance.
Regards, nanitook.

Is this for an anti-exploit? Exploiters can always remove the script that does this so no point in attempting to secure the client really.

1 Like

I mean If I remember correctly you can access the player’s GUIs from the server but I’m not really in expert in anti-exploit scripts.

This isn’t entirely true. The majority of exploiters have very simple exploits, or ones that they didn’t create themselves and have zero understanding of how they work.

Securing the client isn’t going to magically stop exploiters, but it’ll stop a lot of them, surprisingly.


To detect when an instance has been destroyed or removed, you can listen to it’s Parent property.

For example, from a local script:

local gui = -- your path to the instance you want to listen to

local ancestryChanged
ancestryChanged = gui.AncestryChanged:Connect(function()
    if not gui.Parent then
        -- do whatever you want to do when this gui is destroyed.
        ancestryChanged:Disconnect()
        ancestryChanged = nil
    end
end)
2 Likes

The contents of StarterGui are cloned locally to the player’s playerGui when they spawn. So no.

@Fm_Trick maybe a dedicated exploiter would be able to circumvent it, but the point is, it’s still bypassable.

Just in my opinion, attempting to secure the client is the same as not even trying in the first place

1 Like

Oh! My bad, completely forgot that deleting it from the client side won’t show up on the server.

1 Like

Not at all. Since the anti-exploit that I created is on the server side.
But, as @Fm_Trick said, it is as a minimum to stop most of the exploiters that all they do is download a free exploit and scripts, without knowing a minimum part of programming or what they are doing.
Thanks also for your response and opinion. I really appreciate it very much.

Regards!

1 Like