I would highly suggest UserInputService instead.
Now, you probably want it in one of those two ways:
- Pressing all buttons together
For this, you can use IsKeyDown easily. Here's a tutorial:
local UIS = game:GetService("UserInputService")
function onKeyPress(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode.Z then
if UIS:IsKeyDown(Enum.KeyCode.X) and UIS:IsKeyDown(Enum.KeyCode.C) then
end
elseif inputObject.KeyCode == Enum.KeyCode.X then
if UIS:IsKeyDown(Enum.KeyCode.Z) and UIS:IsKeyDown(Enum.KeyCode.C) then
end
elseif inputObject.KeyCode == Enum.KeyCode.C then
if UIS:IsKeyDown(Enum.KeyCode.X) and UIS:IsKeyDown(Enum.KeyCode.Z) then
end
end
end
UIS.InputBegan:connect(onKeyPress)
- Pressing in an order
For this, you can use tick() or os.time() to calculate time passed between button presses.
Here's a tutorial:
local PassedTimeZ = 0
local PassedTimeX = 0
local MaxTime = 0.5
function onKeyPress(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode.Z then
PassedTimeZ = tick()
elseif inputObject.KeyCode == Enum.KeyCode.X then
if PassedTimeZ + MaxTime > tick() then
PassedTimeX = tick()
end
elseif inputObject.KeyCode == Enum.KeyCode.C then
if PassedTimeX + MaxTime > tick() then
end
end
end
IF HELPED, PLEASE UPVOTE AND ACCEPT AS ANSWER THANKS <3 :3
2 comments
I would highly suggest UserInputService instead. In that, you can use
IsKeyDownand I am going to send a tutorial as answer very soon, but still, here's the link: https://wiki.roblox.com/index.php?title=API:Class/UserInputService/IsKeyDown PLEASE UPVOTE THANKS <3Oh and also if you want something like, first Z, then release Z, then press X etc. I'll write for that too. PLEASE UPVOTE THANKS <3