I am making a stamina/sprint script and I made a function that lets you go faster but its not working?
player = script.Parent.Parent.Parent
while true do
wait(.25)
if(script.Parent.Variables.Stamina.Value < 100) then
script.Parent.Variables.Stamina.Value = script.Parent.Variables.Stamina.Value + 1
script.Parent.GUI.Stamina.Text = "Stamina: "..script.Parent.Variables.Stamina.Value.."%"
end
end
function onKeyDown(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode.LeftShift then
if (script.Parent.Variables.Stamina.Value > 0) then
local humanoid = player.Character:FindFirstChild("Humanoid")
humanoid.WalkSpeed = 25
end
end
end
game:GetService("UserInputService").InputBegan:connect(onKeyDown)
And how would I make it to were when the key goes up, it stops the Sprint

2 comments
Sorry I don't have time to answer this, but I can give you something that will help. Here's a video I made on it: https://www.youtube.com/watch?v=9bggLpCFMOg, and the module: https://www.roblox.com/Custom-events-library-Create-or-modify-events-item?id=398814042
Please look at my answer below I provided, It adds to the stamina, but It wont increase my speed