How do I make a loop that happens while a tool is Activated?

Please help me, I need help how to create a loop that will run while a tool is activated.

local tool = -- define tool
local Activated = false

tool.Activated:Connect(function()
  Activated = true
  while Activated do
    -- loop
  end
end

tool.Unequipped:Connect(function()
  Activated = false
end
2 Likes

Thanks for the help, but I say that while the player is holding the mouse button there is a loop, but when he releases the loop it stops

1 Like