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

Keycode is not a valid member of InputObject, help?

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"

1 comment

0

Make sure it's WalkSpeed and not Walkspeed.

1 answer

✓ Accepted answer

Try KeyCode instead of Keycode

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