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
7 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.

01b = script.Parent
02script.Parent.Humanoid.HealthChanged:connect(function()
03if script.Parent.Humanoid.Health <= 0 then
04b.Center.Transparency = 1
05b.Center.CanCollide = false
06b.Part1.Anchored = false
07b.Part2.Anchored = false
08b.Part3.Anchored = false
09b.Part4.Anchored = false
10b.Part5.Anchored = false
11b.Part6.Anchored = false
12b.Part7.Anchored = false
13b.Part8.Anchored = false
14b.Part9.Anchored = false
15b.Part10.Anchored = false
View all 25 lines...

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