It’s not fitting the regular bar size and it’s either going out of the bar when I start to run or not showing. I’m confused as to why this is happening considering that I got the right barsize? Maybe I made a mistake or something.
Video:
Picture:
local UserinputService = game:GetService("UserInputService")
local camera = game.Workspace.CurrentCamera
local TweenService = game:GetService("TweenService")
local player = game:GetService("Players").LocalPlayer
local StaminaGui = player.PlayerGui:FindFirstChild("Stamina")
local Bar = StaminaGui:WaitForChild("Bar")
local BarBackround = StaminaGui:WaitForChild("BarBackround")
---
local Character = player.Character or player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local RunAnimation = script:WaitForChild("Animation[Naruto]")
local Track = Humanoid:LoadAnimation(RunAnimation)
---
local Walk = 16
local Run = 32
local Power = 10
local sprinting = false
local FOVChanges = {
FieldOfView = 90
}
local FOVChanges2 = {
FieldOfView = 70
}
local Info = TweenInfo.new(1, Enum.EasingStyle.Quint, Enum.EasingDirection.Out, 0,false,0)
local CameraTween = TweenService:Create(camera, Info, FOVChanges)
local CameraTween2 =TweenService:Create(camera, Info, FOVChanges2)
UserinputService.InputBegan:Connect(function(input, IsTyping)
if IsTyping then return end
if input.KeyCode == Enum.KeyCode.LeftControl then
Character.Humanoid.WalkSpeed = Run
sprinting = true
while Power > 0 and sprinting do
Power = Power -.03
Bar.Size = UDim2.new(Power / 709,0, 15)
CameraTween:Play()
task.wait()
if Power <= 0 then
Character.Humanoid.WalkSpeed = Walk
end
end
end
end)
UserinputService.InputEnded:Connect(function(input, IsTyping)
if IsTyping then return end
if input.KeyCode == Enum.KeyCode.LeftControl then
Character.Humanoid.WalkSpeed = Walk
sprinting = false
while Power < 10 and sprinting == false do
Power = Power + .03
Bar.Size = UDim2.new(Power / 709,0, 15)
CameraTween2:Play()
task.wait()
if Power <= 0 then
Character.Humanoid.WalkSpeed = Walk
end
end
end
end)