Receiving an invalid EnumItem error

This is my error:

17:30:02.840 - 1 is not a valid EnumItem

This is the code:

-- Services
local replicatedStorage = game:GetService("ReplicatedStorage")
local userInputService = game:GetService("UserInputService")

-- Variables
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local remoteEvent = replicatedStorage.ElementsRemoteEvents.Fire.FireballRain.FireballRainRemoteEvent
local playerMouse = player:GetMouse()

-- Settings
local debounce = true
local key = '1'

userInputService.InputBegan:Connect(function(input, isTyping)
if isTyping then return end
local keyPressed = input.KeyCode
if keyPressed == Enum.KeyCode[key] and debounce and character then
debounce = false
remoteEvent:FireServer(playerMouse.Hit)
wait(1)
debounce = true
end
end)

Can you put a 1 in the key variable?

1 Like

The key code for the 1 character is Enum.KeyCode.One. If you want to use the one in the number pad, you can use NumpadOne.

4 Likes

Thanks!!!

TAGs: HEART BUTTON IS NOT WORKING

‘1’ is not a valid Enum for KeyCode.

Wait, but, how can I but the Numpad? With Enum.NumpadOne?

Enum.KeyCode.NumpadOne would be it

2 Likes

Okay, thanks!!!

TAGS: Hear button not working

Why I receive this error now:

17:37:16.603 - NumpadOne is not a valid EnumItem

image

I think it’s Keypad and not Numpad

X is not a valid member of Y exceptions are easy to fix. You should ben able to fix them yourself. Looks like the key code is KeypadOne

I already gave you the link to the Enum.KeyCode webpage above; it’s on the Developer Hub. You could have found what you needed there, or searched it yourself.


https://gyazo.com/7ff6a79e54195506980482b461d5c8e7