My health bar is tweening the wrong way, it’s tweening to the middle, but it has to tween from right to left.
Any fix?
while wait() do
if Player.Character.Humanoid.Health <= 25 then
script.Parent.PlayerFrame.Health.Bar.BackgroundColor3 = Color3.fromRGB(255,0,0)
else
script.Parent.PlayerFrame.Health.Bar.BackgroundColor3 = Color3.fromRGB(0,255,0)
end
script.Parent.PlayerFrame.Health.Bar.Size = UDim2.new(0, (Char:WaitForChild("Humanoid").Health / Char:WaitForChild("Humanoid").MaxHealth * 230), 1, 0)
--the 230 at MaxHealth * 230 means that the frame size is 230.
end
Your issue is that your AnchorPoint.X value is set to 0.5, which is the ‘halfway point’ (or ‘the middle’). To fix this, set it to 0.
an unusual choice for a health bar, but let’s work with it.
Everything works from left to right. Reading, writing, in this case- tweening. To make it go backwards (right to left) you must use negative numbers. The line of code to tween your health bar should look something like this:
*also, try to refrain from using while loops for this sort of thing. Similarly to what @AridFights1 said, there are events that work perfectly for what you are trying to do. In this case, I recommend tweening your health bar when the Humanoid.HealthChanged event is fired.