This is a script that changes a custom health bar's color and size when damaged. The script detects when the enemy humanoid's health is changed, and changes the custom health bar color.
But I need the size of Y in the Gui to change. I could do ,0,0,12 next to "char.MaxHealth" and it works, but it looks funky and changes size depending on your camera position and how close it is to the Gui health bar.
I want the 0,0,12 to be {0, 0},{0.6, 0} which will fix the problem, but I don't know how to format it after "char.MaxHealth"
local char = script.Parent.Parent.Parent.Parent.Parent.Humanoid
char.Changed:Connect(function()
local redzone = char.MaxHealth/2.5
if char.Health <= redzone then
script.Parent.ImageColor3 = Color3.fromRGB(255,0,0)
end
if char.Health > redzone then
script.Parent.ImageColor3 = Color3.fromRGB(41, 255, 119)
end
script.Parent.Size = UDim2.new(char.Health/char.MaxHealth({0, 0},{0.6, 0})) --The problem.
end)
Error, "Workspace.GummyBear.HealthBar.HealthGui.HealthFrame.Health.HealthScript:11: attempt to call a number value"

2 comments
stop
YES THANKS SO MUCH. The first option worked!! I tried the second but it didn't work.