Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I do multiple keybinds?

Asked by 5 years ago
Edited 5 years ago

So I want to make this program but when there are two of them running at the same time, none of them works. Also, if you don't mind, can you explain me how this code works?

function onKeyPress(actionName, userInputState, inputObject)
    if userInputState == Enum.UserInputState.Begin then
        script.Parent.YAAA:FireServer()
    end
end

game.ContextActionService:BindAction("keyPress", onKeyPress, false, Enum.KeyCode.R)


function onKeyPress(actionName, userInputState, inputObject)
    if userInputState == Enum.UserInputState.Begin then
        script.Parent.Fire:FireServer()
    end
end

game.ContextActionService:BindAction("keyPress", onKeyPress, false, Enum.KeyCode.E)

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Try this

game.ContextActionService:BindAction("keyPress", onKeyPress, false, Enum.KeyCode.R,Enum.KeyCode.E)

Or this

function onKeyPress(actionName, userInputState, inputObject)
    if userInputState == Enum.UserInputState.Begin then
        script.Parent.YAAA:FireServer()
    end
end

game.ContextActionService:BindAction("keyPress", onKeyPress, false, Enum.KeyCode.R)


function onKeyPressT(actionName, userInputState, inputObject)
    if userInputState == Enum.UserInputState.Begin then
        script.Parent.Fire:FireServer()
    end
end

game.ContextActionService:BindAction("keyPress2", onKeyPressT, false, Enum.KeyCode.E)
0
This didn't work, it only binds to the 2nd function I want each of them to have their own function superbolt999 36 — 5y
0
Have you tried the seccond solution Dalbertjdplayz 37 — 5y
0
Thank you superbolt999 36 — 5y
0
If this questions answers the issue @superbolt999 can you mark this question as the answer? Warriorfoox 25 — 5y
Ad

Answer this question