local userInput = game:GetService("UserInputService")
local players = game:GetService("Players")
local sprintSpeed = 25
local walkSpeed = 16
local maxSprint = 10 local staminaCount = maxSprint
local player = players.LocalPlayer
local function beginSprint(input, gameProcessed)
if not gameProcessed then
if input.UserInputType == Enum.UserInputType.Keyboard then
local keycode = input.KeyCode
if keycode == Enum.KeyCode.LeftShift then
player.Character.Humanoid.WalkSpeed = sprintSpeed
if staminaCount > 0 then
repeat
wait(.5)
staminaCount -= .5
script.Parent.Size = UDim2.new(staminaCount/maxSprint,0,.16,1)
until
staminaCount <= 0
if staminaCount <= 0 then
player.Character.Humanoid.WalkSpeed = walkSpeed
repeat
wait(.5)
staminaCount += .5
script.Parent.Size = UDim2.new(staminaCount/maxSprint,0,.16,0)
until
staminaCount == 10
end
end
end
end
end
end
local function endSprint(input, gameProcessed)
if not gameProcessed then
if input.UserInputType == Enum.UserInputType.Keyboard then
local keycode = input.KeyCode
if keycode == Enum.KeyCode.LeftShift then
player.Character.Humanoid.WalkSpeed = walkSpeed
repeat
wait(.5)
staminaCount += .5
until
staminaCount == 10
end
end
end
end
userInput.InputBegan:Connect(beginSprint)
userInput.InputEnded:Connect(endSprint)
i need help fixing things like the choppyness of it, when it fills up you cant start using the sprint again to make it go back down and when it fills up all the way it doesnt stop when the bar is full. any help?
