Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Would there be a way to make models explode after a certain number of damage has been taken?

You know those brick by brick models that are un anchored and have different parts of the model flying when hit by a rocket? Would there be a way to have those different parts of the model flying when it has taken a certain amount of damage?

1 comment

0

basically, when the model somehow has a health, and the health drops down to a certain amount, it explodes?

1 answer

✓ Accepted answer

First off, the model has to have a Humanoid. A Humanoid is the basic unit of life in Roblox. So..

local explosion = Instance.new("Explosion")
explosion.BlastRadius = 5 -- I don't think this would matter
explosion.BlastPressure = 10000000 -- This matters
function Explode()
	if human.Health == 0 then -- 0 is just a number you want to have representing health left
		local expl2 = explosion:Clone()
		expl2.Position = script.Parent.PrimaryPart.Position
		expl2.Parent = script.Parent
		script.Parent:BreakJoints()
	end
end
local human = Instance.new("Humanoid")
human.MaxHealth = -- number of desired maximum health here
human.Health = human.MaxHealth
human.Parent = script.Parent -- Script's Parent is a model
human.Health.Changed:Connect(Explode)

1 comment

0

You shouldnt do a loop like that to detect whether or not the health is the amount you want. Use an event to detect when the health changes and then explode it when that change is to the amount of health you want.

This discussion is preserved as it was. New answers, comments, and votes are closed.