How can I make it so when I call a function the mouse disappears and if I call it again it reappears?

As the title says, how can I make it so when I call a function the mouse disappears and if I call it again it reappears?

Thank you!

I don’t think the mouse has something that can toggle its visibility. You could try changing its icon.

--LocalScript
local player = game:GetService("Players").LocalPlayer
local mouse = player:GetMouse()
local icon = mouse.Icon
local visible = true

local function toggleIcon()
    visible = not visible
    if visible then
        mouse.Icon = icon
    else
        mouse.Icon = --blank icon id here
    end
end
UserInputService.MouseIconEnabled = not UserInputService.MouseIconEnabled