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

Roblox - When Using UserInput Nothing Happens? [Solved]

[Solved by Kiriot22]

Basically I am making a script where when you press enter it will do something. I am using UserInput to do this but for some reason when I press enter it does nothing. I have no errors or warnings in the console. I am using a local script. The code is:

game:GetService("UserInputService").InputBegan:Connect(function(input)
   if input.KeyCode == Enum.KeyCode.Return then
   print("Hey! You pressed enter!")
   end
end)

Any suggestions? It's in workspace but I think it might need to be somewhere else.

8 comments

0

use :Connect not :connect

0

is this a normal or localscript

0

LocalScript

0

Are there any loops above that? Where is this script location?

0

This script works for me?

0

Check to see if your script is disabled.

0

Not disabled.

0

Do (input, gameProcessed).

2 answers

Pay attention to capitals, and make sure you are using a local script. :connect should be :Connect if the code is still not working, make sure you have the local script somewhere where it will be run.

game:GetService("UserInputService").InputBegan:Connect(function(input)
   if input.KeyCode == Enum.KeyCode.Return then
   print("Hey! You pressed enter!")
   end
end)

If this helped please accept the answer so we can both get rep+ :)

1 comment

0

This does not solve the problem. the problem may be the location or other things. but it is good to remember to use :Connect

It doesn't work because LocalScripts don't run in workspace (for obvious reasons). You should put it into StarterPlayerScripts or StarterCharacterScripts or such.

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