easy sprint script

lua keybinded sprint

by TheUniCoder

Author Avatar

sprint keybind scripting :)

so basically imma show you how to make a sprinting script keybind which in this tutorial will

be used as "L" but will be lowercase so dont confuse the L with an I.

lets get started

first we are going to set up the variables and get it all ready for the true coding part to make

thing easier for us in the long run
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

of course im going to also add another variable in which will be the binded key "L" (lowercase) and i will

also make a variable for the running/sprinting speed which ill make "25"
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

local bind = "l"
local sprint = "25"

next is setting it to set up to be keybinded by using a function

so we will use a fuction script to connect the script to react with a certain keypress

basing off the variables we set earlier
player = game.Players.LocalPlayer
mouse = player:GetMouse()

bind = "l"
sprint = "25"

mouse.KeyDown:Connect(function(key)

end)

now that we have a KeyDown function time to set it to the key we want binded

player = game.Players.LocalPlayer
mouse = player:GetMouse()

bind = "l"
sprint = "25"

mouse.KeyDown:Connect(function(key)
    if key == bind then

    end
end)

now of course time to add the script to change the walk speed to the desired sprint speed

player = game.Players.LocalPlayer
mouse = player:GetMouse()

bind = "l"
sprint = "25"

mouse.KeyDown:Connect(function(key)
    if key == bind then
        player.Character.Humanoid.WalkSpeed = sprint
    end
end)

now to make it so when you release the key you go back to roblox default walkspeed (16)

player = game.Players.LocalPlayer
mouse = player:GetMouse()

bind = "l"
sprint = "25"

mouse.KeyDown:Connect(function(key)
    if key == bind then
        player.Character.Humanoid.WalkSpeed = sprint
    end
end)

mouse.KeyUp:Connect(function(key)
    if key == bind then
        player.Character.Humanoid.WalkSpeed = 16
    end
end)

hope this helped someone :D

View in-game to comment, award, and more!