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

Userinput service is not working. Help???

Asked by 3 years ago
local inputServe = game:GetService("UserInputService")
inputServe.InputBegan:Connect(function(input, gameProccesedEvent)
    if input.KeyCode == Enum.KeyCode.G then
        print("G pressed.")
    end
end)

There is no errors that happened. It's in a local script, and its in starterplayerscripts

0
I actually copied your original code and it worked just fine, perhaps there's something else wrong with your code? BIuehawks 62 — 3y
0
This is not really an endearing question.. Ziffixture 6913 — 3y
0
Things to check: Is script disabled? Is there inf loop before this code (common mistake)? Is this function firing at all (put print before if statement)? Is your keyboard working properly? sleazel 1287 — 3y
0
what happened here greatneil80 2647 — 3y
0
erease ", gameProccessedEvent" and it will work Necro_las 412 — 3y

4 answers

Log in to vote
0
Answered by 3 years ago

Hi, try changing 'input' in your function parameters to something else, like this

local inputServe = game:GetService("UserInputService")
inputServe.InputBegan:Connect(function(inputKey, gameProccesedEvent)
    if inputKey.KeyCode == Enum.KeyCode.G then
        print("G pressed.")
    end
end)
1
I dont wanna sound toxic, but the parameters are not the issue here. THUNDER_WOW 203 — 3y
1
It fixed my issue at one point, not sure if it was just a loose variable that it was taking or what. BIuehawks 62 — 3y
0
Well its a different case for every script cause every script works in a different way, depending on how you scripted it. THUNDER_WOW 203 — 3y
1
InputObject & GameProcessedInput are the most appropriate parameter names. Ziffixture 6913 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

Unless there is something else in your script this should be working.

game:GetService("UserInputService").InputBegan:Connect(function(Input)
    if Input.KeyCode == Enum.KeyCode.G then
        print("G Pressed.")
    end
end)
Log in to vote
0
Answered by 3 years ago

Add a LocalScript to StarterGui and type this:

local Service = game:GetService("UserInputService")
Input.InputBegan:Connect(function(Input)
    if Input.KeyCode == Enum.KeyCode.G then
        print("G was pressed")
    end
end)
Log in to vote
0
Answered by 3 years ago

I Had This Error Too, First It Has To be In A Local Script And Try To Put The Local Script In The Backpack

Answer this question