Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to make a tool change with Mouse wheel?

I want to make a tool change with the mouse wheel, like on COR 5 Roblox at War. I've read several post. Here are the only two scripts i can find.

local player = game.Players.LocalPlayer
Not tested

local character = player.Character or player.CharacterAdded:wait()
local humanoid = character:WaitForChild("Humanoid")
local mouse = player:GetMouse()

local backpack = player:WaitForChild("Backpack")
local toolList = backpack:GetChildren() -- put in your tools

local currentTool = 1

local equipTool(toolNumber)
humanoid:EquipTool(toolList[toolNumber])
currentTool = toolNumber
end

mouse.WheelBackward:connect(function()
equipTool((currentTool > 0 and (currentTool - 1)) or 9)
end)

mouse.WheelForward:connect(function()
equipTool((currentTool < 9 and (currentTool + 1)) or 0)
end)

The second one is

local player = game.Players.LocalPlayer
local char = player.Character

local mouse = player:GetMouse()
local tool = 0

mouse.WheelForward:connect(function()
   tool = tool + 1
   if tool >= 5 then --change 5 to how many tools you have
      tool = tool - tool --resets it back to 0 so it equips the first tool again
   end
end)
mouse.WheelBackward:connect(function()
   tool = tool - 1
   if tool <= 0 then
      tool = tool + tool - tool + 5 --sets it to 5 so it equips the last ool
   end
end)

while wait() do
   if tool == 0 then
      --remove all tools before adding the first tool, same with the rest.
   elseif tool == 1 then

   elseif tool == 2 then

   elseif tool == 3 then

   elseif tool == 4 then

   elseif tool == 5 then

   end
end

Now, if either of these two scripts would work, could someone please tell me how to configure them. (Where to put the tools, where to put the script, ect.) If neither of them would work, could someone please tell me a script to use, and how to configure it. Your help would be greatly appreciated.

1 comment

0

Please help me

1 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.