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

Scale Player Health with a UDim2?

Asked by 4 years ago

I have a slight problem that I don't know if it's even that easy to solve but... It's worth a try. I have been trying to create a cool health system with hearts that scale with your health,such as Terraria if anybody has seen the health system. Your hearts get smaller as you lose health,now this itself wouldn't be a problem,but I want it different.Each heart represents 20 Health Points,with the Roblox amount of HP is 100,meaning 5 hearts with 20 each.Let's say that you lost 10 HP.If you have lost that 10 hp then it would bring your first heart to half of it's original size,after that you lost 10 yet again and the first heart is gone,but now you move onto the second heart exactly like this,but the first heart doesnt grow back to its original size until your health gets back at that certain point.

I tried doing something with a Heart Counter to manage which heart was the turn to get smaller but.. I ended up rage quitting after I saw that i couldn't make it past the UDim2 (Don't laugh at me please)

wait(3)
local player = game.Players.LocalPlayer
local HeartCounter = 1


player.Character.Humanoid.HealthChanged:Connect(function(health)
    if health <= player.Character.Humanoid.MaxHealth and health >= player.Character.Humanoid.MaxHealth-20 then  --This asks if the HP is 100-20, which is how many health points a heart usually contains,20.
      HeartCounter = 1
    else
      HeartCounter = 2
    end
end)

player.Character.Humanoid.HealthChanged:Connect(function()
    if HeartCounter == 1 then

    end
end)

Answer this question