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

Is it possible to make a keybinding script that uses 2 keys?

Asked by 5 years ago
Edited 5 years ago

Basically,like a front flip animation to work.It will need to press the keys Z and X is it possible?

I'm not trying to say can you script it for me.

0
You can use the IsKeyDown method of UserInputService User#19524 175 — 5y

2 answers

Log in to vote
0
Answered by
Vulkarin 581 Moderation Voter
5 years ago

You can use GetKeysPressed

local uis = game:GetService("UserInputService")

uis.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.Z or input.KeyCode == Enum.KeyCode.X then
        local keys = uis:GetKeysPressed()
        local xFound, zFound
        for _, key in pairs(keys) do
            if key.KeyCode == Enum.KeyCode.Z then 
                zFound = true
            elseif key.KeyCode == Enum.KeyCode.X then
                xFound = true
            end
        end

        if zFound and xFound then
            print("both keys")
        end
    end
end)

1
Sorry for the most LATEST reply but thanks!It worked rochel89 42 — 5y
0
no problem Vulkarin 581 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

I think that it is possible. Try something like this:

local uis = game:GetService("UserInputService")

uis.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.Z and input.KeyCode == Enum.KeyCode.X then
        -- Code here
    end
end)

-- Not quite sure will this work ^^
0
that wouldn't work, InputBegan will fire twice (once for Z, once for X) Vulkarin 581 — 5y
0
nice try tho rochel89 42 — 5y
0
thx bro AswormeDorijan111 531 — 5y

Answer this question