contextActionService = game:GetService("ContextActionService") local mobilebutton = contextActionService:BindAction("KeyX",KeyX,true,"H",Enum.KeyCode.ButtonY) contextActionService:SetPosition("KeyX",UDim2.new(0.72,-25,0.30,-25)) contextActionService:SetTitle("KeyX","X")
Im Not sure how i would fire a function to make it do a combo like if you press Z+X+C then print the combo you did.
I would highly suggest UserInputService instead.
Now, you probably want it in one of those two ways:
1) 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 --The code end elseif inputObject.KeyCode == Enum.KeyCode.X then if UIS:IsKeyDown(Enum.KeyCode.Z) and UIS:IsKeyDown(Enum.KeyCode.C) then --Same code above end elseif inputObject.KeyCode == Enum.KeyCode.C then if UIS:IsKeyDown(Enum.KeyCode.X) and UIS:IsKeyDown(Enum.KeyCode.Z) then --Totally same code above end end end UIS.InputBegan:connect(onKeyPress)
2) 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 --The Code end end end
IF HELPED, PLEASE UPVOTE AND
ACCEPT AS ANSWER THANKS <3 :3