To use the :Resize method with a tween, you can create a new vector that specifies the new size for the positive axis of the health bar. Here’s an example:
character:WaitForChild("Humanoid").HealthChanged:Connect(function()
local sizeX = (character:WaitForChild("Humanoid").Health / character:WaitForChild("Humanoid").MaxHealth) * 7
local tween = game:GetService("TweenService"):Create(GreenBar, TweenInfo.new(.25, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0), {
Size = Vector3.new(sizeX, GreenBar.Size.Y, GreenBar.Size.Z) -- tween the Size property
})
-- create a new vector with the resized positive axis
local newVector = Vector3.new(-sizeX/2, GreenBar.Size.Y/2, GreenBar.Size.Z/2)
newVector:Resize(Enum.NormalId.Left, -1) -- resize only the positive axis
-- tween the CFrame property of the Part to move the positive axis of the health bar
local partTween = game:GetService("TweenService"):Create(Part, TweenInfo.new(.25, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0), {
CFrame = GreenBar.CFrame * CFrame.new(newVector)
})
tween:Play()
partTween:Play() -- play both tweens simultaneously
end)