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!

5 comments
So where it says (tool) do I put the tool name in the brackets?
It's not working, sorry.
Sorry, I found what was going wrong. You change InputChanged to InputBegan. My bad! Thanks!
Is there a way to unequip the tool?
Found it. It's UnequipTools(). Cheers!