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

Trying to learn about Gamepad inputs, don't know what lines 3-4 do?

I'm learning about Gamepad inputs. The following code is supposed to get the available KeyCodes for the Gamepad2. I do not understand what is happening in lines 3-4. Please explain what these lines do.

local availableInputs = game:GetService("UserInputService"):GetSupportedGamepadKeyCodes(Enum.UserInputType.Gamepad2)
print("This controller supports the following controls:")
for _, control in pairs(availableInputs) do
	print(control)
end

1 answer

✓ Accepted answer
for _, control in pairs(availableInputs) do
    print(control)
end

What this line does in your code above is that it essentially checks your controller for what controls it has because roblox does not only support xbox one controllers but other controllers can be used to play roblox as well so its needed to check what inputs the controller that the player is using has.

2 comments

0

thanks. what does "control" refer to in the line with the for loop?

0

It refers to all the controls on the players controller so it loops through the controls and prints their names.

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