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

Both Costume Health and Humanoid-Health Regeneration Doesnt Work!?

Asked by 6 years ago

So i was making my game when i ran into an unexpected proplem that wasnt even in error log

anway

Experimental mode : off Filtering enabled = on

my code for costume health

local plr = game.Players.LocalPlayer

plr.CharacterAdded:Connect(function(character)
local Humanoid = plr.Character:WaitForChild("Humanoid")
local HG = script.Parent
local Text = HG:WaitForChild("Back"):WaitForChild("Text")
local hlth = Humanoid.Health
local mxhlth = Humanoid.MaxHealth


Humanoid.Health.Changed:Connect(function()
Text:TweenSize(UDim2.new(hlth/mxhlth,0, 1,0), "Out", "Linear", .2, true)
end)

end)

also can someone tell me why regeneration script wont work? i have made a script to see if its disabled when the player enters but no still no work

i am talking about the "health" script when the player character is ingame``

0
Please properly indent your code. It makes reading and debugging it so much easier. For yourself and others. User#21908 42 — 6y
0
how i do that @Phlegethon5778 adamdeno 2 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

Try this:

local plr = game.Players.LocalPlayer

plr.CharacterAdded:Connect(function(character)
    local Humanoid = character:WaitForChild("Humanoid")
    local HG = script.Parent
    local Text = HG:WaitForChild("Back"):WaitForChild("Text")

    Humanoid.Health.Changed:Connect(function()
        local Math = Humanoid.Health / Humanoid.MaxHealth
        Text:TweenSize(UDim2.new(Math,0, 1,0), "Out", "Linear", 0.2, true)
    end)
end)

The reason it didn't work is because you made a variable for health and maxhealth meaning that the values always stayed the same. Though the health is changing since the value is the same your "text" doesn't change.

Hopefully, this helped.

Best of luck developer!

0
Ohhhhh now i know how to fix it BEST THANK FOR YOU adamdeno 2 — 6y
0
No problem anytime BlackOrange3343 2676 — 6y
Ad

Answer this question