game.Players.PlayerAdded:connect(function(Player) ting = true Mouse = Player:GetMouse() function scroll() if ting == true then ting = false --change weapon wait (1) ting = true end end) Mouse.WheelBackward:connect(scroll) Mouse.WheelForward:connect(scroll)
NOTE: I only need 2 weapons, but I'd like to know if I need to do something different for 3,4,etc...
To do this then you should follow these steps:
1) - Make a table
full of all the tools you want the player to have access to
2) - Make a variable for how you'll index the table.
3) - Change the variable according to the WheelForward
and WheelBackward
Events
4) Replace the tools in the character with the WheelForward
and WheelBackward
Events, and index the tool table according to the variable.
Should look something like this;
NOTE: This should be a localscript in StarterGui
local tools = {} --Tool table local plr = game.Players.LocalPlayer --Player local mouse = plr:GetMouse() --Mouse local toolIndex = 1 --Variable for indexing tools table repeat wait() until plr.Character --Wait for character local char = plr.Character function clearTools(c) --Function to remove tools for i,v in pairs(c:GetChildren()) do if v:IsA('Tool') or v:IsA('HopperBin') then v:Destroy() end end end function replaceTool(c) local tool = tools[toolIndex] if tool then clearTools(c) tool:Clone().Parent = c end end mouse.WheelForward:connect(function() toolIndex = toolIndex + 1 replaceTool(char) end) mouse.WheelBackward:connect(function() toolIndex = toolIndex - 1 replaceTool(char) end)