function onKeyPress(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode.Space then
print("hi")
end
end
✓ ANSWER ACCEPTED
Can't get this to work when i click the space key?
1 answer
✓ Accepted answer
You aren't calling the function. So basically, the script can use those lines of code, but not until you say it can. This is in a local script by the way. The efficiant way of doing this is...
game:GetService('UserInputService').InputBegan:connect(function(inputObject)
if inputObject.KeyCode == Enum.KeyCode.Space then
print("hi")
end
end)
Refer to http://wiki.roblox.com/index.php?title=API:Class/UserInputService/InputBegan for even more help
This discussion is preserved as it was. New answers, comments, and votes are closed.
