Hello. I am trying to make my custom healthbar health subtract to the left side. The problem is it goes to the middle instead.
I tried editing some variables for the equation to subtract the health. No success.
the script i used is here:
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
humanoid.HealthChanged:Connect(function(Health)
script.Parent.Size = UDim2.new(Health/humanoid.MaxHealth, 0,1,0)
end)
i wasnt exactly sure what you meant by “switching the Humanoid/MaxHealth on the Y-axis scale of the GUI” but i tried this:
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
humanoid.HealthChanged:Connect(function(Health)
script.Parent.Size = UDim2.new(humanoid.MaxHealth/Health, 0,1,0)
end)
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
humanoid.HealthChanged:Connect(function(Health)
script.Parent.Size = UDim2.fromScale(math.clamp(Health/humanoid.MaxHealth, 0,1), 1)
end)