Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i make this short ''sound effect'' playing when this crate gets damaged?

Asked by
ali7682 17
6 years ago

I'm trying to make a crate that has Health and each time that it gets damaged, no matter how much damage you'll hear a little ''sound effect'' playing. However, if the Health = 0 or lower, you won't hear the sound effect playing no matter how much it get's damaged. So, i have a model. Inside that model i have a bunch of parts (18) that make the crate, i have a script (the script will make the parts unanchored once the Health = 0 or lower), and i have a Humanoid in the model (stats are Maxhealth = 100 and Health = 100) The sound ID i want it to play when it gets damaged = 550208601 Here is my script if you need it.

b = script.Parent
script.Parent.Humanoid.HealthChanged:connect(function()
if script.Parent.Humanoid.Health <= 0 then
b.Center.Transparency = 1
b.Center.CanCollide = false
b.Part1.Anchored = false
b.Part2.Anchored = false
b.Part3.Anchored = false
b.Part4.Anchored = false
b.Part5.Anchored = false
b.Part6.Anchored = false
b.Part7.Anchored = false
b.Part8.Anchored = false
b.Part9.Anchored = false
b.Part10.Anchored = false
b.Part11.Anchored = false
b.Part12.Anchored = false
b.Part13.Anchored = false
b.Part14.Anchored = false
b.Part15.Anchored = false
b.Part16.Anchored = false
b.Part17.Anchored = false
b.Part18.Anchored = false
end
end)

I'm not the best at scripting so there might be things in this script that i could make shorter or something. You can help me with that too :D. Thanks!

Answer this question