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.
local player = game.Players.LocalPlayer local char = player.Character or player.CharacterAdded:wait() game:GetService("UserInputService").InputChanged:connect(function(iO,gPE) if not gPE then if iO.UserInputType == Enum.UserInputType.MouseWheel then print(iO.Position.Z) local LastTool = nil local Pos = 1 for i,v in pairs(char:GetChildren())do if v:IsA'Tool'then LastTool = v end end char.Humanoid:UnequipTools() for i,v in pairs(player.Backpack:GetChildren())do if v==LastTool then Pos = i end end if iO.Position.Z == 1 then if Pos == 1 then Pos = #player.Backpack:GetChildren() char.Humanoid:EquipTool(player.Backpack:GetChildren()[Pos]) wait() else Pos = Pos-1 char.Humanoid:EquipTool(player.Backpack:GetChildren()[Pos]) wait() end elseif iO.Position == -1 then if Pos == #player.Backpack:GetChildren() then Pos = 1 char.Humanoid:EquipTool(player.Backpack:GetChildren()[Pos]) wait() else Pos = Pos+1 char.Humanoid:EquipTool(player.Backpack:GetChildren()[Pos]) wait() end end end end end)
Closed as Not Constructive by Goulstem
This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.
Why was this question closed?