Scroll wheel tool change broken, can someone help? [closed]
Can someone tell me whats wrong with this fix and possibly fix it. I did not make this script btw but I really need it to work. It's supposed to cycle through tools with use of scroll wheel. The forward wheel works with switching weapons, but the scrollwheel back unequips all tools and doesn't equip a new one.
01 | local player = game.Players.LocalPlayer |
02 | local char = player.Character or player.CharacterAdded:wait() |
03 | game:GetService( "UserInputService" ).InputChanged:connect( function (iO,gPE) |
05 | if iO.UserInputType = = Enum.UserInputType.MouseWheel then |
09 | for i,v in pairs (char:GetChildren()) do |
14 | char.Humanoid:UnequipTools() |
15 | for i,v in pairs (player.Backpack:GetChildren()) do |
20 | if iO.Position.Z = = 1 then |
22 | Pos = #player.Backpack:GetChildren() |
23 | char.Humanoid:EquipTool(player.Backpack:GetChildren() [ Pos ] ) |
27 | char.Humanoid:EquipTool(player.Backpack:GetChildren() [ Pos ] ) |
30 | elseif iO.Position = = - 1 then |
31 | if Pos = = #player.Backpack:GetChildren() then |
33 | char.Humanoid:EquipTool(player.Backpack:GetChildren() [ Pos ] ) |
37 | char.Humanoid:EquipTool(player.Backpack:GetChildren() [ Pos ] ) |