Hello, I have a problem with the stamina scaling and health bar that are displayed in the video below. I need the bar to drain from top to bottom because it currently drains from the right to left side. Although I tried to adjust the AnchorPoint, I wasn’t able to find a solution. Would someone kindly assist?
Script here:
local Player = game.Players.LocalPlayer
while not Player.Character do wait() end
local Character = Player.Character
local Humanoid = Character:WaitForChild("Humanoid")
local Healthbar = script.Parent.Health.Bar
local Redbar = script.Parent.Health.Red
local Stambar = script.Parent.Stamina.Bar
local maxhealth = 100
local maxstamina = 100
local TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(
.2,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out
)
Player.Character.Humanoid:GetPropertyChangedSignal("Health"):Connect(function()
local newTween = TweenService:Create(Healthbar,tweenInfo,{Size = UDim2.new(Humanoid.Health/maxhealth,0,1,0)})
newTween:Play()
wait(.2)
local newTween2 = TweenService:Create(Redbar,tweenInfo,{Size = UDim2.new(Humanoid.Health/maxhealth,0,1,0)})
newTween2:Play()
end)
Player:WaitForChild("States"):WaitForChild("Stamina").Changed:Connect(function()
local newTween = TweenService:Create(Stambar,tweenInfo,{Size = UDim2.new(Player.States.Stamina.Value/maxstamina,0,1,0)})
newTween:Play()
end)
i do this by moving the bar as its size is reduced, because it gets closer to the top left as it shrinks.
Position = UDim2.new(0,0,1,0) --Places bar at bottom
.Size = UDim2.new(1,0,0,0) --Makes bar flat
TweenService:Create(Instance,Info,{ Size = UDim2.new(1,0,Y,0), Position = UDim2.new(0,0,1-Y,0) }
it’s something like that, i really only make the bar go from 0 to 1, not to any point between like in your case