I’m currently making a stamina bar for my sprint script, ive got the tweening to work partially but it just does weird stuff. I’m not too good with tweening but im pretty sure all the easing directions and styles are right, the stamina bar just resizes itself when i just want the bar to move side to side, which it does but it gets wider aswell and then covers the end of the border of the bar at the end. like it goes to far to the end if that makes sense
heres a video
https://gyazo.com/a2e4f3d92a06070051f11023b2bc3392
My local script:
local function sprint(active)
if Exhausted then return end -- we can't run because we're exhausted!
if active then
player.Character:FindFirstChildWhichIsA("Humanoid").WalkSpeed = player.Character:FindFirstChildWhichIsA("Humanoid").WalkSpeed + sprintSpeed
else
player.Character:FindFirstChildWhichIsA("Humanoid").WalkSpeed = player.Character:FindFirstChildWhichIsA("Humanoid").WalkSpeed - sprintSpeed
end
sprinting = active
end
local runService = game:GetService("RunService")
local insideBar = script.Parent
runService.Heartbeat:Connect(function(DeltaTime)
if sprinting then
if stamina > 0 then
stamina = stamina - DrainRate * DeltaTime
insideBar:TweenSize(UDim2.new(stamina / 100,0,1,0),Enum.EasingDirection.Out,Enum.EasingStyle.Linear,0.5,false,nil)
else
sprint(false)
Exhausted = true
end
elseif stamina < 100 then
stamina = stamina + DrainRate * DeltaTime
insideBar:TweenSize(UDim2.new(stamina / 100,0,1,0),Enum.EasingDirection.In,Enum.EasingStyle.Linear,0.5,false,nil)
if stamina > RunRefresh then -- we can now run again!
Exhausted = false
if SprintHeld then -- resume running because player is still holding down the sprint key!
sprint(SprintHeld)
end
end
end
end)
uis.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
SprintHeld = true
sprint(SprintHeld)
end
end)
uis.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
SprintHeld = false
sprint(SprintHeld)
end
end)