I'm trying to make a vehicle that is destructible with Humanoid. I can't seem to get it to work.
I want the smoke to enable when the health is at 1000.
But every time I make the health lower to 1000 from 2000, it does nothing. Here's the code I've made that didn't work:
local health = script.Parent.Humanoid local damage1 = script.Parent.DamageInd.Smoke if health.Health == 1000 then damage1.Enabled = true wait() end
However, if I start the Test with 1000, it'll work, but it won't work if i manually change it through properties or shoot at it, it doesn't.
the DamageInd is the brick that has the fire/smoke. This script was placed within the model of the vehicle. The Humanoid was placed in it too.
I basically need to find a way to tell the script to "look again."
Your script only works once, and that is immediately when it starts running. It will not check again. Using the HealthChanged
event, you can do your check. HealthChanged fires whenever the health changes, whether it be an increase or decrease, which should be when you're checking.
local humanoid = script.Parent.Humanoid local damage1 = script.Parent.DamageInd.Smoke humanoid.HealthChanged:Connect(function(health) -- health is the new health of the humanoid if health >= 1000 then -- the health might be 1000.24146 and that isn't exactly 1000, so >= damage1.Enabled = true end end)