Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Can't get this to work when i click the space key?

function onKeyPress(inputObject, gameProcessedEvent) 
	if inputObject.KeyCode == Enum.KeyCode.Space then

print("hi")

	end
end

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.