Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

Roblox - When Using UserInput Nothing Happens? [Solved]

Asked by 5 months ago
Edited 5 months 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 — 5mo
0
is this a normal or localscript fanofpixels 591 — 5mo
0
LocalScript KingDomas 7 — 5mo
0
Are there any loops above that? Where is this script location? yHasteeD 1573 — 5mo
View all comments (3 more)
0
This script works for me? kingdom5 5316 — 5mo
0
Check to see if your script is disabled. upVector 802 — 5mo
0
Not disabled. KingDomas 7 — 5mo

2 answers

Log in to vote
0
Answered by 5 months 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 1573 — 5mo
Ad
Log in to vote
0
Answered by
Kiriot22 3080 Moderation Voter Community Moderator
5 months 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