Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
VVired 28
7 years ago

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
0
What are you trying to do? Make a custom HP bar? SimpleFlame 255 — 7y
0
If it doesn't reset after you die, then did you make sure the StarterGui resets after death? Click StarterGui > Check "ResetPlayerGuiOnSpawn" Theevilem 23 — 7y
0
Why do you have lines 12-18? e-e TheeDeathCaster 2368 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

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
Ad

Answer this question