1 | local inputServe = game:GetService( "UserInputService" ) |
2 | inputServe.InputBegan:Connect( function (input, gameProccesedEvent) |
3 | if input.KeyCode = = Enum.KeyCode.G then |
4 | print ( "G pressed." ) |
5 | end |
6 | end ) |
There is no errors that happened. It's in a local script, and its in starterplayerscripts
Hi, try changing 'input' in your function parameters to something else, like this
1 | local inputServe = game:GetService( "UserInputService" ) |
2 | inputServe.InputBegan:Connect( function (inputKey, gameProccesedEvent) |
3 | if inputKey.KeyCode = = Enum.KeyCode.G then |
4 | print ( "G pressed." ) |
5 | end |
6 | end ) |
Unless there is something else in your script this should be working.
1 | game:GetService( "UserInputService" ).InputBegan:Connect( function (Input) |
2 | if Input.KeyCode = = Enum.KeyCode.G then |
3 | print ( "G Pressed." ) |
4 | end |
5 | end ) |
Add a LocalScript to StarterGui and type this:
1 | local Service = game:GetService( "UserInputService" ) |
2 | Input.InputBegan:Connect( function (Input) |
3 | if Input.KeyCode = = Enum.KeyCode.G then |
4 | print ( "G was pressed" ) |
5 | end |
6 | end ) |
I Had This Error Too, First It Has To be In A Local Script And Try To Put The Local Script In The Backpack