Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Roblox - When Using UserInput Nothing Happens? [Solved]

Asked by
KingDomas 153
6 years ago
Edited 6 years ago

[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.

0
use :Connect not :connect tacotown2 119 — 6y
0
is this a normal or localscript fanofpixels 718 — 6y
0
LocalScript KingDomas 153 — 6y
0
Are there any loops above that? Where is this script location? yHasteeD 1819 — 6y
View all comments (4 more)
0
This script works for me? User#5423 17 — 6y
0
Check to see if your script is disabled. nilVector 812 — 6y
0
Not disabled. KingDomas 153 — 6y
0
Do (input, gameProcessed). 9mze 193 — 5y

2 answers

Log in to vote
0
Answered by 6 years ago

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+ :)

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 yHasteeD 1819 — 6y
Ad
Log in to vote
0
Answered by
Amiaa16 3227 Moderation Voter Community Moderator
6 years ago

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

Answer this question