I have a crosshair Gui that follows the mouse when the tool is equipped. But when I unequip it, the output says:
This mouse is no longer active
tool.Equipped:connect(function(mouse)
print("Tool equipped!")
-- Open Crosshair GUI
local gui = tool.CrosshairGUI
local guiClone = gui:Clone()
guiClone.Parent = player.PlayerGui
-- Move Crosshair GUI to mouse position
local crosshairClone = guiClone:FindFirstChild("Crosshair")
while wait() do
local mousePosX = mouse.X -- It says this line is the problem
local mousePosY = mouse.Y -- Same with this one
crosshairClone.Position = UDim2.new(0, mousePosX - 25 , 0, mousePosY - 25)
-- Hide mouse
game:GetService("UserInputService").MouseIconEnabled = false
tool.Unequipped:connect(function()
-- Delete Crosshair GUI
guiClone:Destroy()
wait()
-- Show mouse
game:GetService("UserInputService").MouseIconEnabled = true
end)

4 comments
problems are at line 14 and 15
Try adding a "if not mouse then return end" inside the while loop.
Stll says that the mouse is not active
If this is a LocalScript, use GetMouse