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

user input service not working?

Asked by 5 years ago

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?

0
1. Use it in a LocalScript and make sure the LocalScript is not in either Workspace or ServerScriptService. DeceptiveCaster 3761 — 5y
0
no Gameplayer365247v2 1055 — 5y
0
dumb DeceptiveCaster 3761 — 5y
0
ur dumb for thinking it goes in the serverscriptservice or workspace Gameplayer365247v2 1055 — 5y
View all comments (3 more)
0
read my answer that works Gameplayer365247v2 1055 — 5y
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] Mr_Unlucky 1085 — 5y
0
He didn't state that it should be in Workspace or ServerScriptService [2]. Mr_Unlucky 1085 — 5y

2 answers

Log in to vote
6
Answered by 5 years ago
Edited by User#24403 5 years ago

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)
0
Thank you. That's a lot better. DeceptiveCaster 3761 — 5y
0
we cant let gamer's answer get accepted User#24403 69 — 5y
0
you all should upvote cuz i want next rank lol mattchew1010 396 — 5y
0
Upvote y'all because this is the best answer so far Mr_Unlucky 1085 — 5y
Ad
Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

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
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 Gameplayer365247v2 1055 — 5y
0
uhhhhhhhhh why not use the input parameter passed by InputBegan smh DeceptiveCaster 3761 — 5y

Answer this question