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)