This is my code so far:
1 | function onKeyPress(inputObject, gameProcessedEvent) |
2 | if inputObject.KeyCode = = Enum.KeyCode. 32 then |
3 | print ( "Space was pressed" ) |
4 | end |
5 | end |
6 |
7 | game:GetService( "UserInputService" ).InputBegan:connect(onKeyPress) |
Erroring at line 2. Dont know how to refer to a number.
The space bar has a value of 32, not a name. Use this page as a reference:
1 | function onKeyPress(inputObject, gameProcessedEvent) |
2 | if inputObject.KeyCode = = Enum.KeyCode.Space then |
3 | print ( "Space was pressed" ) |
4 | end |
5 | end |
6 |
7 | game:GetService( "UserInputService" ).InputBegan:connect(onKeyPress) |