Sprint script not working because of shiftlock

So I was watching a youtube tutorial on how to create a shift to sprint script, and I was able to follow everything. But when it came to testing, when I pressed shift all it did was go to shiftlock. But the youtube tutorial didn’t have any shiftlock on their screen, and worked fine on theirs.

This is my script:

local uis = game:GetService(“UserInputService”)

local player = game:Players.LocalPlayer

local char = workspace:WaitForChild(player.Name)

local run = 30

local walk = 16

uis.InputBegan:Connect(function(input)

if input.KeyCode == Enum.KeyCode.LeftShift then

char.Humanoid.WalkSpeed = run

end

end)

uis.InputEnded:Connect(function(input)

if input.KeyCode == Enum.KeyCode.LeftShift then

char.Humanoid.WalkSpeed = Walk

end)

How to fix your problem, pick a single one that you like the most:

  1. Turn off shiftlock in the roblox menu for yourself and try again
  2. Turn off shiftlock in roblox studio so no one can use shiftlock and that will solve problem for everyone
  3. Change button for running so it doesn’t conflict with shiftlock button
  4. Change shiftlock button in the studio so it doesn’t conflict with run button
2 Likes

The only things I can see that would be wrong are:

  • You are missing an end in the last conditional.
  • The “walk” variable is being used wrong. ( You need to watch capital letters )
  • You used a colon in the wrong place when accessing Players. ( Correct: game.Players )

Fixed Code:

local uis = game:GetService(“UserInputService”)
local player = game.Players.LocalPlayer
local char = workspace:WaitForChild(player.Name)
local walk = 16
local run = 30

uis.InputBegan:Connect(function(input)

    if input.KeyCode == Enum.KeyCode.LeftShift then

        char.Humanoid.WalkSpeed = run

    end

end)

uis.InputEnded:Connect(function(input)

    if input.KeyCode == Enum.KeyCode.LeftShift then

        char.Humanoid.WalkSpeed = walk

    end

end)
1 Like

If you want to disable shift lock and set it to another button I think you can use ContextActionService:GetAllActions() or smthn like that. ContextActionService | Roblox Creator Documentation

1 Like