Hello. Try using UserInputService as Mouse.KeyDown
is deprecated. Try this:
01 | local UserInputService = game:GetService( "UserInputService" ) |
03 | local anim = Instance.new( "Animation" ) |
06 | local plr = game:GetService( "Players" ).LocalPlayer |
07 | local mouse = plr:GetMouse() |
09 | local char = plr.Character or plr.CharacterAdded:Wait() |
10 | local human = char:WaitForChild( "Humanoid" ) |
12 | local track = human:LoadAnimation(anim) |
13 | track.Priority = Enum.AnimationPriority.Action |
15 | UserInputService.InputBegan:Connect( function (input, gameProcessedEvent) |
16 | if input.KeyCode = = Enum.KeyCode.LeftShift and not gameProcessedEvent then |
22 | UserInputService.InputEnded:Connect( function (input, gameProcessedEvent) |
23 | if input.KeyCode = = Enum.KeyCode.LeftShift and not gameProcessedEvent then |
The InputBegan
function fires when an input is detected. Then there's an if statement checking if the input is left shift and that the player isn't in chat. Then it plays the animation and changes the walkspeed.