Basically what I'm doing is I'm making some scripts for gamepads. Simple enough. But then I try to add a table/list of the things in the players backpack. So far they are two items called "HiP" and "LinkedSword". What I want to be able to do is call upon the table/list and then scroll through the tools. This would involve the user pressing DPadLeft or DPadRight and then the tool changing (I can sort of do that). Here is my script so far (I removed the table/list as it keeps breaking the darn thing):
userInputService.InputBegan:connect(function(input, processed) if input.UserInputType == Enum.UserInputType.Gamepad1 then if input.KeyCode == Enum.KeyCode.DPadRight then game.Players.LocalPlayer.Character.Humanoid:EquipTool(player.Backpack.HiP) end end end)
I'll also need help with the changing of the tool, as if it were to be for example:
game.Players.LocalPlayer.Character.Humanoid:EquipTool(tools[1]) -- tools being the name of the table
then if the user pressed DPadRight then it would just change through all of the tools, as if there were, say, three tools, there would be three separate parts that say:
userInputService.InputBegan:connect(function(input, processed) if input.UserInputType == Enum.UserInputType.Gamepad1 then if input.KeyCode == Enum.KeyCode.DPadRight then game.Players.LocalPlayer.Character.Humanoid:EquipTool(tools[1]) end end end) userInputService.InputBegan:connect(function(input, processed) if input.UserInputType == Enum.UserInputType.Gamepad1 then if input.KeyCode == Enum.KeyCode.DPadRight then game.Players.LocalPlayer.Character.Humanoid:EquipTool(tools[2]) end end end) userInputService.InputBegan:connect(function(input, processed) if input.UserInputType == Enum.UserInputType.Gamepad1 then if input.KeyCode == Enum.KeyCode.DPadRight then game.Players.LocalPlayer.Character.Humanoid:EquipTool(tools[3]) end end end)
which wouldn't work. Thanks for any help.