This is a stamina script, Im currently trying to make it so when you jump it takes away
local TweeningService = game:GetService("TweenService")
local UIS = game:GetService('UserInputService')
local Bar = script.Parent
local player = game.Players.LocalPlayer
local NormalWalkSpeed = 16
local NewWalkSpeed = 18
local power = 10
local sprinting = false
repeat wait() until game.Players.LocalPlayer.Character
local character = player.Character
--= Tween Functions =--
-- sprinting
local FOVChanges = {
FieldOfView = 90
}
local TweenInformation = TweenInfo.new(
1, --tween length
Enum.EasingStyle.Quint, --easing Style
Enum.EasingDirection.Out, --easing Direction
0, --repitition time
false, --reverse?
0 --delay
)
local tween = TweeningService:Create(camera,TweenInformation,FOVChanges)
-- walking
local FOVChanges2 = {
FieldOfView = 70
}
local TweenInformation2 = TweenInfo.new(
1, --tween length
Enum.EasingStyle.Quint, --easing Style
Enum.EasingDirection.Out, --easing Direction
0, --repitition time
false, --reverse?
0 --delay
)
local tween2 = TweeningService:Create(camera,TweenInformation2,FOVChanges2)
--= Functions =--
UIS.InputBegan:connect(function(key, gameProcessed)
if key.KeyCode == Enum.KeyCode.LeftShift and gameProcessed == false then
character.Humanoid.WalkSpeed = NewWalkSpeed
sprinting = true
while power > 0 and sprinting do
power = power - .03
Bar.Size = UDim2.new(power / 10, 0, 1, 0)
--Bar.BackgroundColor3 = Bar.BackgroundColor3:lerp(Color3.fromRGB(255, 42, 42), 0.001)
tween:Play()
wait()
if power <= 0 then
character.Humanoid.WalkSpeed = NormalWalkSpeed
end
end
end
end)
UIS.InputEnded:connect(function(key, gameProcessed)
if key.KeyCode == Enum.KeyCode.LeftShift and gameProcessed == false then
character.Humanoid.WalkSpeed = NormalWalkSpeed
sprinting = false
while power < 10 and not sprinting do
power = power + .03
Bar.Size = UDim2.new(power / 10, 0, 1, 0)
--Bar.BackgroundColor3 = Bar.BackgroundColor3:lerp(Color3.fromRGB(255, 166, 11), 0.001)
tween2:Play()
wait()
if power <= 0 then
character.Humanoid.WalkSpeed = NormalWalkSpeed
end
end
end
end)