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

user input service not working?

For some reason user input service is not working for me, I just started to learn about this so i know next to nothing about it, but i've watched alot of tutorials, copying there code that makes it so if i press A, the output will say you pressed A. And i even went to the roblox dev hub, and copied the code straight from there, and its still not working, What am i doing wrong?

7 comments

0
  1. Use it in a LocalScript and make sure the LocalScript is not in either Workspace or ServerScriptService.
0

no

0

dumb

0

ur dumb for thinking it goes in the serverscriptservice or workspace

0

read my answer that works

0

Lmao, he has way more reputation than you, not to mention you posted an answer in https://scriptinghelpers.org/questions/78987/how-to-disable-the-jumping-while-inside-a-vehicledrive-seat stating that the reason why his code wasn't working was because he forgot to put a SPACE. And finally, he said that you should make sure that the LocalScript ins't in the Workspace or ServerScriptService. [1]

0

He didn't state that it should be in Workspace or ServerScriptService [2].

2 answers

✓ Accepted answer

iv'e never seen the thing that gamer posted so here's what i do:

local uis = game:GetService("UserInputService") -- get the service

uis.InputBegan:Connect(funtion(Input) --calls the function when anything is pressed
	if Input.KeyCode == Enum.KeyCode.A then --check if the keycode is A this is case sensitive in other words make sure your caps are correct
		print("A was pressed")
	end
end)

4 comments

0

Thank you. That's a lot better.

0

we cant let gamer's answer get accepted

0

you all should upvote cuz i want next rank lol

0

Upvote y'all because this is the best answer so far

make sure its a local script and is in the starterpack after that for userinputservice to work u need the line

 if game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.key here) then
--function here
end

2 comments

0

also make sure there is no gui in the starterpack or they wont work, i had it there for some reason once and nothing from starterpack worked at that point

0

uhhhhhhhhh why not use the input parameter passed by InputBegan smh

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