Ok, so far I have created a script that will change the players walkspeed if they hold the L3 button on a gamepad. Next, I need the code to select a tool when pressed. If I press ButtonY, then it should select tool1. To be honest, all I need is for someone to tell me how to select a tool if a certain button is pressed, or an event occurs. I've come up with this so far:
--Left ThumbStick(Click) - Sprint -- Make variables for services local userInputService = game:GetService("UserInputService") local runService = game:GetService("RunService") -- Make variables for player, character, and camera local player = game.Players.LocalPlayer while not player.Character do wait() end local character = player.Character userInputService.InputEnded:connect(function(input, processed) if input.UserInputType == Enum.UserInputType.Gamepad1 then if input.KeyCode == Enum.KeyCode.ButtonL3 then character.Humanoid.WalkSpeed = 16 end end end) userInputService.InputBegan:connect(function(input, processed) if input.UserInputType == Enum.UserInputType.Gamepad1 then if input.KeyCode == Enum.KeyCode.ButtonL3 then character.Humanoid.WalkSpeed = 30 end end end) userInputService.InputChanged:connect(function(input, processed) if input.UserInputType == Enum.UserInputType.Gamepad1 then if input.KeyCode == Enum.KeyCode.ButtonY then -- this is where the tool selection part would go end end end)
Thanks for any help!
Well, you could easily use the EquipTool
event
game.Players.LocalPlayer.Character.Humanoid:EquipTool(tool)
So it will look like
userInputService.InputChanged:connect(function(input, processed) local tool = game.Players.LocalPlayer.Backpack:FindFirstChild("Tool Name") if input.UserInputType == Enum.UserInputType.Gamepad1 then if input.KeyCode == Enum.KeyCode.ButtonY then game.Players.LocalPlayer.Character.Humanoid:EquipTool(tool) end end end)
Hope it helped, if not comment on this!
Thanks, -Lost