Binding multiple keys to one action?

game:GetService('ContextActionService'):BindActionAtPriority('Place', inputPlace, false, 9, Enum.UserInputType.MouseButton1)

What I want to be able to do is bind multiple keys to this one action. So I want if the player clicks, touch (for mobile/tablet) or presses A (gamepad) it to work. I tried doing what I have below for just pc and tablet,

game:GetService('ContextActionService'):BindActionAtPriority('Place', inputPlace, false, 9, Enum.UserInputType.MouseButton1, Enum.UserInputType.Touch)

But this just breaks everything. There are no errors in the output.

1 Like

Well, that’s exactly how it’s supposed to work. Out of curiosity, have you tried mixing up the input types? And what is the “9” there?

4 Likes

Same problem, any update on this?

I’m pretty sure this is because there is only one input argument for each BindAction, so to fix it all you have to do is create another one.

local cas = game:GetService("ContextActionService")

local function inputPlace()
	-- Code
end

cas:BindActionAtPriority("Place", inputPlace, false, 9, Enum.UserInputType.MouseButton1)
cas:BindActionAtPriority("Place2", inputPlace, false, 9, Enum.UserInputType.Touch)

Hope I helped.

1 Like

This isn’t true. InputTypes is a tuple, so can make as many as possible

Yea you’re right and I think I found the solution!

local cas = game:GetService("ContextActionService")

local function inputPlace()
	print("test")
end

cas:BindActionAtPriority("Place", inputPlace, false, 9, Enum.KeyCode.Y, Enum.KeyCode.Z)

This works because roblox doesn’t use the Z or Y key for anything in their default scripts when you load the game. I don’t know how you would get it to work with inputs they do use though (Unless you unbind them).