Greetings dear developers!
I have a script here that allows one or another part to fall off the model if its health becomes zero… And I would like to know how to make this script act not only on one part, but on several parts at once. That is, so that it is not necessary to multiply this script and put it in each part separately.
Thank you for attention.
And here is the script itself, if you please:
if script.Parent.Velocity.Magnitude > hit.Velocity.Magnitude + 3 and hit.CanCollide == true or hit.Velocity.Magnitude >
script.Parent.Health.Value = script.Parent.Health.Value - script.Parent.Velocity.Magnitude / 1.25
if script.Parent.Health.Value <= 100 and script.Parent.Health.Value >= 0 then
if script.Parent.Health.Value <= 0 then
–local e = Instantce.new(“Explosion”, script.Parent.Parent.Parent)
–e.BlastPressure = 50
–e.BlastRadius = 1
–e.Position = script.Parent.Position
if script.Parent.Health.Value > 50 then
script.Parent.Sparks.Enabled = true
local sound = math.random(1, 2)
if sound == 1 then
script.Parent.Collide.SoundId = “rbxassetid://490314550”
if sound == 2 then
script.Parent.Collide.SoundId = “rbxassetid://215550851”
script.Parent.Collide.Playing = true
script.Parent.Sparks.Enabled = false
script.Disabled = false
script.Disabled = true
script.Parent.CanCollide = true
script.Parent.Break.Playing = true
script.Parent.Parent = workspace
Forgive me if there was a mistake somewhere, because I wrote it by hand.