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 5 years ago
Edited 5 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. :)

01local Player = game.Players.LocalPlayer
02Player.CharacterAdded:wait()
03 
04local Mouse = Player:GetMouse()
05local Speed = 33
06local Humanoid = Player.Character:WaitForChild("Humanoid")
07local OrigSpeed = Humanoid.WalkSpeed
08local active = false
09 
10Mouse.KeyDown:connect(function(Key)
11local Code=Key:byte()
12    if Key == Enum.KeyCode.LeftShift and active == false then
13        Humanoid.WalkSpeed = Speed
14        active = true
15    elseif Key == Enum.KeyCode.LeftShift and active == true then
16        Humanoid.WalkSpeed = OrigSpeed
17        active = false
18    end
19end)

1 answer

Log in to vote
1
Answered by 5 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