Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

Why won't this shift to sprint script function?

Asked by 4 years ago
Edited 4 years ago

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

Log in to vote
1
Answered by 4 years ago

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.

Ad

Answer this question