I'm making a barrel that can explode, but it doesn't want to work no matter what I do. To make things more clear I'm using a normal script, Humanoid, Torso, Head
This is the script, nothing functions... :
Heater = script.Parent.Torso Neon = script.Parent.Head Humanoid = script.Parent.Humanoid Fire = Heater.Fire Smoke = Heater.Smoke if Humanoid.Health <= 75 then Neon.BrickColor = BrickColor.new("Bright yellow") end if Humanoid.Health <= 50 then Neon.BrickColor = BrickColor.new("Orange") Fire.Enabled = true end if Humanoid.Health <= 25 then Neon.BrickColor = BrickColor.new("Crimson") end if Humanoid.Health == 0 then Exp = Instance.new("Explosion") Exp.BlastPressure = 100000 Exp.BlastRadius = 7.5 Exp.Parent = game.Workspace Exp.Position = Heater.Position Heater:Destroy() Neon:Destroy() end
Hope you can find the error and help me fix it, please !
Your script only runs once when the game first starts. To make it update every time the player’s health is changed, you must check the health every time the property changes.
Heater = script.Parent.Torso Neon = script.Parent.Head Humanoid = script.Parent.Humanoid Fire = Heater.Fire Smoke = Heater.Smoke Humanoid:GetPropertyChangedSignal("Health"):Connect(function() if Humanoid.Health <= 75 and Humanoid.Health > 50 then Neon.BrickColor = BrickColor.new("Bright yellow") elseif Humanoid.Health <= 50 and Humanoid.Health > 25 then Neon.BrickColor = BrickColor.new("Orange") Fire.Enabled = true elseif Humanoid.Health <= 25 and Humanoid.Health > 0 then Neon.BrickColor = BrickColor.new("Crimson") elseif Humanoid.Health <= 0 then Exp = Instance.new("Explosion") Exp.BlastPressure = 100000 Exp.BlastRadius = 7.5 Exp.Parent = game.Workspace Exp.Position = Heater.Position Heater:Destroy() Neon:Destroy() end end)