ChildRemoved not working for me!

Hey I learned about ChildRemoved and wanted to try it out to see if I can check if a Player deletes a script

local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait() 

Character.ChildRemoved:connect(function(Object)
    print(Object.Name .. " removed from the Workspace")
end) 

But when ever I test and delete the LocalScript in StarterCaracther scripts, nothing happens

This is my first question ever posted on devforum please let me now if I did something wrong, Thanks! :smiley:

Delete it from the Character. Scripts in StarterCharacterScripts are cloned into the Character, and they run in the Character.

So say I was a Hacker, (I know it isnt the best to prevent exploits on the Client) and I got into the Explorer, etc in the game and I deleted the script on StarterCarctherScripts would this cause any affect?

You got a typing error there man

Correct it to

Character.ChildRemoved:Connect(function(object)

In the second line of your code

Typos cost you a lot while coding brother

1 Like

StarterCharacterScripts are cloned to the player once they load in. Hackers are not able to remove scripts that are cloned to other players, so they couldn’t prevent other players from having the script cloned. As @sjr04 said, to test it, you should remove the script from the actual Character instead of StarterCharacterScripts. As far as anti-exploits go, attempting to prevent exploits on the client is utterly useless, as exploiters can just remove the scripts that are trying to stop them. You are much better off creating checks on the server. As for your code, connect is deprecated, use Connect instead.

I changed it but no luck still

So when you guys mean by

Would you find a copy of the script inside of the player and delete it from there?

Yep! That’s what you’ll want to do to test this. StarterCharacterScripts is just the folder that stores these scripts in the explorer, when the game is run and players are added, it clones these scripts inside the Character.

Alright! I’ll try that out :smiley:

The print statement still isn’t running, I went into workspace and deleted the script from the Player/Caracther Model.

Are you deleting the local script? don’t delete it, if you delete it it would stop running

Yeah I am deleting the Local script, is there a different apporach I should go at it?

Don’t delete the actual script that is attempting to check if other scripts are deleted. Test it with an empty script. It can’t detect if itself is deleted.

I’m trying to check if the actual Local Script is being deleted, Is there something that I could call that will prevent the script from being deleted and still print the message?