local mouse = game.Players.LocalPlayer:GetMouse()
local running = false
function getTool()
for _, kid in ipairs(script.Parent:GetChildren()) do
if kid.className == "Tool" then return kid end
end
return nil
end
mouse.KeyDown:connect(function (key) -- Run function
key = string.lower(key)
if string.byte(key) == 48 then
running = true
local keyConnection = mouse.KeyUp:connect(function (key)
if string.byte(key) == 48 then
running = false
end
end)
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = game.Players.LocalPlayer.Stats.Agility.Value + 30
repeat wait () until running == false or game.Players.LocalPlayer.Stamina.Value <= 0
keyConnection:disconnect()
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16
end
end)
mouse.KeyDown:connect(function (key)
key = string.lower(key)
if string.byte(key) == 48 then
running = true
while running == true and game.Players.LocalPlayer.Stamina.Value > 0 do
game.Players.LocalPlayer.Stamina.Value = game.Players.LocalPlayer.Stamina.Value-2
print("Gay")
if game.Players.LocalPlayer.Stamina.Value <= 2 then
game.Players.LocalPlayer.Stamina.Value = 0
end
wait(0.1)
end
running = false
end
end)
It sprints based on player's agility and drains the player's stamina by 2 every 1/10th of a second(second block of code)
Experimented until it worked, but I have a strong feeling that there will be a bug somewhere and it can be improved

1 comment
You shouldn’t be using KeyDown.