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)
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)
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)
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
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