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

Keycode is not a valid member of InputObject, help?

Asked by 3 years ago

I keep getting errors whenever I run this This is a sprinting mechanic btw

local UserInputService = game:GetService("UserInputService")
local player = game.Players.LocalPlayer``
local char = player.Character
KeyPressed = false

UserInputService.InputBegan:Connect(function(input,gameProcessedEvent)
    if input.Keycode == Enum.KeyCode.LeftShift then
        KeyPressed = true
    end
end)

UserInputService.InputEnded:Connect(function(input,gameProcessedEvent)
    if input.Keycode == Enum.KeyCode.LeftShift then
        KeyPressed = false
    end
end)

if KeyPressed == true then
    char.Humanoid.Walkspeed = 32
else
    char.Humanoid.Walkspeed = 16
end

Errors: Players.Flasker917.PlayerScripts.LocalScript:21: attempt to index nil with 'Humanoid' Keycode is not a valid member of InputObject "InputObject"

0
Make sure it's WalkSpeed and not Walkspeed. sidewinder44 20 — 3y

1 answer

Log in to vote
0
Answered by
imKirda 4491 Moderation Voter Community Moderator
3 years ago
Edited 3 years ago

Try KeyCode instead of Keycode

Ad

Answer this question