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.
01 | while true do |
02 | wait( 0.1 ) |
03 | if script.Parent.Humanoid.Health < 100 then |
04 | script.Parent.Head.Break:Play() |
05 | script.Parent.Head.ParticleEmitter.Enabled = true |
06 | wait( 0.1 ) |
07 | script.Parent.Head.ParticleEmitter.Enabled = false |
08 | script.Parent.Head.Static:Destroy() |
09 | wait( 0.1 ) |
10 | script.Parent:Destroy() |
11 | break |
12 | end |
13 | end |
Try something like:
01 | while true do |
02 | wait( 0.1 ) |
03 | if script.Parent.Humanoid.Health < 100 then |
04 | script.Parent.Head.Break:Play() |
05 | script.Parent.Head.ParticleEmitter.Enabled = true |
06 | wait( 0.1 ) |
07 | script.Parent.Head.ParticleEmitter.Enabled = false |
08 | script.Parent.Head.Static.PlaySoundOnRemove = false |
09 | script.Parent.Head.Static.Volume = 0 |
10 | script.Parent.Head.Static:Stop() |
11 | script.Parent.Head.Static:Destroy() |
12 | wait( 0.1 ) |
13 | script.Parent:Destroy() |
14 | break |
15 | end |
16 | end |
It's pretty hacky, but it should work.
Make sure you check the "PlayOnRemove" next time.
01 | script.Parent.Head:FindFirstChild( "Break" ).PlayOnRemove = true |
02 | while true do |
03 | wait( 0.1 ) |
04 | if script.Parent.Humanoid.Health < 100 then |
05 | script.Parent.Head.Break:Play() |
06 | script.Parent.Head.ParticleEmitter.Enabled = true |
07 | wait( 0.1 ) |
08 | script.Parent.Head.ParticleEmitter.Enabled = false |
09 | script.Parent.Head.Static:Destroy() |
10 | wait( 0.1 ) |
11 | script.Parent:Destroy() |
12 | break |
13 | end |
14 | end |