I tried this:
script.Parent.Touched:Connect(function(Hit) Hit = nil end)
Setting a part to nil should destroy it, why doesn't this work?
Hello, this is really simple. The reason why nil doesn't remove the instance is that nil is a directory, which is not accessible through scripts. Let's say that nil is the Workspace, but you cannot access it.
Like the person above said, to remove the part you can do
Hit:Destroy()
or
Hit:Remove()
and the part will be wiped off your game.
Nil can be used for many things, such as anti-cheats. The bad part is that exploits parent their scripts to nil so the game cannot detect them.
~ Dan_PanMan, advanced scripter.
No, "setting a part to nil" doesn't destroy it. You were close though. Parenting a part to nil is probably what you were thinking of Hit.Parent = nil
however I wouldn't recommend doing that. It's better to :Destroy()
it.
script.Parent.Touched:Connect(function(Hit) Hit:Destroy() end)