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)

3 comments
Woah, I do not know why the script came out like that...
Edited for code block. In the future, be sure to enclose your code in a code block by highlighting your code and clicking the blue Lua button included in the editor.
Stopped reading at "I did not make this script".