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

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

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``

2 comments

0

Please properly indent your code. It makes reading and debugging it so much easier. For yourself and others.

0

how i do that @Phlegethon5778

1 answer

✓ Accepted answer

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!

2 comments

0

Ohhhhh now i know how to fix it BEST THANK FOR YOU

0

No problem anytime

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