How to make Something happens when any key is pressed

How would i make when Any key is pressed, something happens like destroy a gui Instead of a Play button

image

1 Like

Use userinputservice and check when they press any key
https://developer.roblox.com/en-us/api-reference/class/UserInputService

1 Like

Use UserInputService.InputBegan to detect whenever a player enters input into the game.

Here is an example:

game:GetService("UserInputService").InputBegan:Connect(function(input, gameEvent)
    if gameEvent then return end
    print("Player Entered Some Input", input)
end)

I believe it should work.

2 Likes
local userInput = game:GetService("UserInputService")

userInput.InputBegan:Connect(function(input, processed)
	if processed then
		return
	end
	
	if input.UserInputType == Enum.UserInputType.Keyboard or input.UserInputType = Enum.UserInputType.Touch then
		--Continue past main menu screen.
	end
end)

For keyboard/touchscreen input specifically you would do as shown in the above.

1 Like

The issue with this is that it’ll count mouse input (mouse movement/scrolling) which aren’t technically keys.