Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why won't this shift to sprint script function?

I'd like to implement this short sprint script into my game however it won't work and I can't identify the problem. Your help would be greatly appreciated. :)

local Player = game.Players.LocalPlayer
Player.CharacterAdded:wait()

local Mouse = Player:GetMouse()
local Speed = 33
local Humanoid = Player.Character:WaitForChild("Humanoid")
local OrigSpeed = Humanoid.WalkSpeed
local active = false

Mouse.KeyDown:connect(function(Key)
local Code=Key:byte()
    if Key == Enum.KeyCode.LeftShift and active == false then
        Humanoid.WalkSpeed = Speed
        active = true
    elseif Key == Enum.KeyCode.LeftShift and active == true then
        Humanoid.WalkSpeed = OrigSpeed
        active = false
    end
end) 

1 answer

✓ Accepted answer

Hello. "Mouse.KeyDown" is deprecated now. You should instead use the User Input Service.

Read more about it here:

link

I hope this solved your issue.

This discussion is preserved as it was. New answers, comments, and votes are closed.