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

My custom health isn't working correctly?

I'm making a game that required me to make a custom health. I made the custom health and scripted it. But, it seems it's not working fully right.

game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
local player = game.Players.LocalPlayer
repeat wait() until player.Character
local humanoid = player.Character:WaitForChild("Humanoid")
local TheMathPart = humanoid.Health / (humanoid.MaxHealth)

script.Parent:TweenSize(UDim2.new(0,-215,0,10), "Out", "Sine", .5)

function CustomHealth()
	local TheMathPart = humanoid.Health / (humanoid.MaxHealth)
	script.Parent:TweenSize(UDim2.new(TheMathPart,-215,0,10), "Out", "Sine", .5)
end 

humanoid.HealthChanged:connect(CustomHealth)

The thing is that when I made the health 50%, it went down like it was suppose too. But, when the health started regenerating, it would just keep going instead of going back.

Also...when taken damage the health would move to the right, yet I wanted it to go left...if that makes sense. Basically, I want my health to start toward the right, and when taken damage it would move toward the left. Sorry if I'm confusing everybody!

Help would be very appreciated!

2 comments

0

You didn't include the regenerateing health code.

0

I looked through the object browser and I don't see anything about regenerateing health.

1 answer

Line 7 should be script.Parent:TweenSize(UDim2.new(1,-215,0,10), "Out", "Sine", .5). Use a 1,not a 0 otherwise it won't display.

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