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

Need Help Patching A Sound hack if added to workspace??

im trying to get it were if someone hacks in music which added to workspace it will remove or destroy it but this not working

workspace.ChildAdded:connect(function(l) if l:IsA('Sound') then l:Stop() l:Destroy() end end)

1 answer

✓ Accepted answer

Theres nothing wrong with this, however, if someone hacks, they won't only inject into workspace, thus you'd have to link the event to every instance in the workspace.

Your issue however is that you're trying to set the parent to nil while something else has set the parent to workspace in the same tick. add a wait() and it should work.

another thing to mention: PlayOnRemove value should be set to false to make sure it wont play.

workspace.ChildAdded:connect(function(Object) 
	wait()
	if Object:IsA('Sound') then 
		Object:Stop() 
		Object.PlayOnRemove = false
		Object:Destroy() 
	end 
end)

1 comment

0

What about the "DescendantAdded" event? That'll fire when a descendant is added, wherever the object was added. http://wiki.roblox.com/index.php?title=API:Class/Instance/DescendantAdded

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