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

Why isn't my my exploding barrel script not working... ? (I hate that title requirement...)

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 !

1 comment

0

What's with the (I hate that title requirement...) ? Well, I wanted to give it the same title as it is right now, but it didn't work so i just wrote it there...

1 answer

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)

1 comment

0

Sorry, still does not function, this will not be considered as "Answered"

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