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

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

Asked by 4 years ago
Edited 4 years ago

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

Log in to vote
1
Answered by
Prestory 1395 Moderation Voter
4 years ago
Edited 4 years ago
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.

0
thanks. what does "control" refer to in the line with the for loop? User#28017 0 — 4y
0
It refers to all the controls on the players controller so it loops through the controls and prints their names. Prestory 1395 — 4y
Ad

Answer this question