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

Healthbar script not working!?!??! making me very salty.

I don't know why this isn't working, it was working before. It doesn't seem to reset after I die. It did like 3 hours ago though.

game.Players.LocalPlayer.Character.Humanoid.Changed:connect(function()
script.Parent.Size = UDim2.new(game.Players.LocalPlayer.Character.Humanoid.Health / game.Players.LocalPlayer.Character.Humanoid.MaxHealth,0,0,20)
script.Parent.TextLabel.Text = math.floor(game.Players.LocalPlayer.Character.Humanoid.Health)
 if game.Players.LocalPlayer.Character.Humanoid.Health < 25 then
	script.Parent.BackgroundColor3 = Color3.new(255,0,255)
 else if game.Players.LocalPlayer.Character.Humanoid.Health > 25 then
	script.Parent.BackgroundColor3 = Color3.new(0, 255, 0)
  end
 end
end)

while true do
	if game.Players.LocalPlayer.Humanoid.Health == 100 then
		script.Parent.Size = UDim2.new(1, 0, 0, 20)
		script.Parent.BackgroundColor3 = Color3.new(0, 255, 0)
	end
   wait()
end

3 comments

0

What are you trying to do? Make a custom HP bar?

0

If it doesn't reset after you die, then did you make sure the StarterGui resets after death? Click StarterGui > Check "ResetPlayerGuiOnSpawn"

0

Why do you have lines 12-18? e-e

1 answer

You can manually view the properties of StarterGui and make sure "ResetPlayerGuiOnSpawn" is checked or else it won't reset after death.

OR

You can implement it in a script using this code in your health script!

local starterGui = game:GetService("StarterGui")

starterGui.ResetPlayerGuiOnSpawn = true

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