Does anyone know how to use the new KeyCode API? It's GetKeysPressed, but I don't know how to use it.
I would like it when the letter V is pressed, then I'll add my own code there.
Thanks, -flor
Does anyone know how to use the new KeyCode API? It's GetKeysPressed, but I don't know how to use it.
I would like it when the letter V is pressed, then I'll add my own code there.
Thanks, -flor
local uis = game:GetService("UserInputService")
uis.InputBegan:Connect(function(key,bool)
if bool == false then
if key.KeyCode == Enum.KeyCode.V then
--do stuff here
end
end
end)
Keep in mind this has to be done from a local script.
local uis = game:GetService("UserInputService")
uis.InputBegan:Connect(function(key, bool)
bool = false
if bool == false then
if key.KeyCode == Enum.KeyCode.V then
-- do stuff here
bool = true
end
end
end)
Try that, if it doesn't work, please let me know.
Both of ya'll are wrong. This is the correct way,
Here's the link: http://wiki.roblox.com/index.php?title=Keyboard_input
function onKeyPress(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode.V then
print("V was pressed")
end
end
game:GetService("UserInputService").InputBegan:connect(onKeyPress)
We are not wrong, we are just using a different method / coding differently.
This discussion is preserved as it was. New answers, comments, and votes are closed.
5 comments
It this FilteringEnabled? I'm still trying to learn FilteringEnabled.
The code doesn't seem to work, I put a print statement in the line of code and nothing happened. I used a local script in Workspace.
I'll sort this out for you, bare with me.
Alright
Local script only run from places that are independent to each player, such as their gui. Try putting it in StarterGui.