Checking for Gamepad input within a Gamepad input?

I’m looking to check if someone is pressing ButtonB, then also check if they’re pressing ButtonX. ButtonB is an attack, and ButtonX is a dash.

If this is done correctly, It’ll return end when you press X during B.

You press B to do the attack. But I don’t want people to dash during the attack.

I suppose what you can do is make a variable like:

local Bdown = false

Then make it true when B is down. Then while that is happening you can see if X gets pressed and do whatever you want.

1 Like

The scripts are separate. So Bdown = false wouldn’t exactly work. This is why I was hoping I could register it based on inputs.

Then you can use a bool value?

1 Like

I tried that before and it didn’t work. I guess I’ll do it again. Thanks.

I think what you are looking for is this:

UserInputService:IsGamepadButtonDown

So in your dash script, check if ButtonB is down before you allow them to dash. No need to set a variable for it.

1 Like

I was looking into that, but it confused me a bit. But I guess this IS the real answer.

The basic jist of the script is this…

local userInputService = game:GetService("UserInputService")


local function performDash()
	if userInputService:IsGamepadButtonDown(Enum.UserInputType.Gamepad1,
		Enum.KeyCode.ButtonB) == true then
		return
	end

	-- Perform Humanoid Dash Ability
end

The only drawback is that you will have to figure out which gamepad is active.

1 Like

This is INSANELY helpful. Thank you so much! Does this check have to be a local function?

I always put local function. You can use just function if you want. Doesn’t really hurt anything that I’ve seen.

1 Like

Is there a list of all the Gamepads?

If you go through the list of methods that UserInputService provides, there are a number of gamepad methods:

Are but a few.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.