I have this jammer model that plays static sounds when in distance, and i also have this script that breaks the jammer if shot at. Except the static sound keeps playing AFTER the model has been destroyed. I tried Sound:Stop() and Sound:Destroy() but neither of them worked.
while true do wait(0.1) if script.Parent.Humanoid.Health < 100 then script.Parent.Head.Break:Play() script.Parent.Head.ParticleEmitter.Enabled = true wait(0.1) script.Parent.Head.ParticleEmitter.Enabled = false script.Parent.Head.Static:Destroy() wait(0.1) script.Parent:Destroy() break end end
Try something like:
while true do wait(0.1) if script.Parent.Humanoid.Health < 100 then script.Parent.Head.Break:Play() script.Parent.Head.ParticleEmitter.Enabled = true wait(0.1) script.Parent.Head.ParticleEmitter.Enabled = false script.Parent.Head.Static.PlaySoundOnRemove = false script.Parent.Head.Static.Volume = 0 script.Parent.Head.Static:Stop() script.Parent.Head.Static:Destroy() wait(0.1) script.Parent:Destroy() break end end
It's pretty hacky, but it should work.
Make sure you check the "PlayOnRemove" next time.
script.Parent.Head:FindFirstChild("Break").PlayOnRemove=true while true do wait(0.1) if script.Parent.Humanoid.Health < 100 then script.Parent.Head.Break:Play() script.Parent.Head.ParticleEmitter.Enabled = true wait(0.1) script.Parent.Head.ParticleEmitter.Enabled = false script.Parent.Head.Static:Destroy() wait(0.1) script.Parent:Destroy() break end end