I’m currently making a fighting game, and I want there to be a 3D Viewport health bar, but the issue is that, I want to use the :Resize
method/function of a part while also tweening it so that it isn’t instant. How would I go about doing this?
Code:
local player = game.Players.LocalPlayer
local viewport = script.Parent
local character = player.Character or player.CharacterAdded:Wait()
local GreenBar = viewport:WaitForChild("Health_Green")
local cam = Instance.new("Camera")
viewport.CurrentCamera = cam
cam.Parent = viewport
cam.CFrame = CFrame.new(Vector3.new(-24.784, 0.965, 37.515)) * CFrame.Angles(math.rad(3.307), math.rad(-23.772), math.rad(0))
local Part = Instance.new("Part"):Resize(Enum.NormalId.Left, -1)
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:Play()
end)