I’m new on InputObject, i want to make a script which contain some gamepad and keyboard functions, the problem is that i’m getting an error which i don’t know how to solve:
local navGamepads = UserInputService:GetNavigationGamepads()
for _, gamepad in pairs(navGamepads) do
local supportedKeyCodes = UserInputService:GetSupportedGamepadKeyCodes() --//ERROR LINE
for _, keycode in pairs(supportedKeyCodes) do
if (keycode == Enum.KeyCode.ButtonX) then
ContextActionService:BindAction("SampleAction", actionHandler, false, Enum.KeyCode.ButtonL1)
end
The error is Argument 1 missing or nil , i don’t know what i should change and that stuff, thanks for reading
local UserInputService = game:GetService("UserInputService")
local ContextActionService = game:GetService("ContextActionService")
local function actionHandler(actionName, inputState, inputObj)
if inputState == Enum.UserInputState.Begin then
print("Script is working, now write something else here dumo")
end
end
local navGamepads = UserInputService:GetNavigationGamepads()
for _, gamepad in pairs(navGamepads) do
local supportedKeyCodes = UserInputService:GetSupportedGamepadKeyCodes(Enum.UserInputType.Gamepad1)
for _, keycode in pairs(supportedKeyCodes) do
if (keycode == Enum.KeyCode.ButtonX) then
ContextActionService:BindAction("SampleAction", actionHandler, false, Enum.KeyCode.ButtonL1)
end
if (keycode == Enum.KeyCode.E) then
ContextActionService:BindAction("SampleAction", actionHandler, false, Enum.KeyCode.E)
end
end
end
The script is not working for me, did i made something wrong?:
if (keycode == Enum.KeyCode.ButtonX) then
ContextActionService:BindAction("SampleAction", actionHandler, false, Enum.KeyCode.ButtonL1,Enum.KeyCode.E)
end