Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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.

1 comment

0

You can use the IsKeyDown method of UserInputService

2 answers

✓ Accepted answer

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)

2 comments

1

Sorry for the most LATEST reply but thanks!It worked

0

no problem

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 ^^

3 comments

0

that wouldn't work, InputBegan will fire twice (once for Z, once for X)

0

nice try tho

0

thx bro

This discussion is preserved as it was. New answers, comments, and votes are closed.