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

Registers all other keys but not enter?

local inputHandler = game:GetService("UserInputService")

inputHandler.InputBegan:connect(function(inp)
local itype = inp.UserInputType
local key = inp.KeyCode
if itype == Enum.UserInputType.Keyboard then
if key  == Enum.KeyCode.KeypadEnter then
print("enter pressed")
end
end
end)

This is supposed to print something when enter was pressed, however, it does not work at all. It only works for all other keys.

No output, no nothing. Help me out here? Cheers.

1 answer

✓ Accepted answer

It's way easier than that, lol.

local uis=game:GetService("UserInputService") --Getting UserInputService

uis.InputBegan:connect(function(key) --When a player presses a button on the keyboard
    if key.KeyCode==Enum.KeyCode.Return then --if they pressed enter
        print("Pressed Enter")
    else --otherwise print what they pressed
        print("Enter not pressed, "..tostring(key.KeyCode).." pressed instead.")
    end
end)

2 comments

0

Your code does not work at all.

0

Sorry, lol. Fixed.

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