Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Mouse is no longer active?

Asked by
PhaZeRO 30
8 years ago

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)
0
problems are at line 14 and 15 PhaZeRO 30 — 8y
0
Try adding a "if not mouse then return end" inside the while loop. Kryddan 261 — 8y
0
Stll says that the mouse is not active PhaZeRO 30 — 8y
0
If this is a LocalScript, use GetMouse Shawnyg 4330 — 8y

Answer this question