How to hide Custom Cursor while on the Pause Menu?

So this is the Custom Cursor I have for my game
RobloxStudioBeta_0Ju4hP848S

What I wanna do is whenever you open the ROBLOX pause menu…
image_2022-12-09_001249049
The custom cursor would disappear and it would be the regular ROBLOX one
RobloxStudioBeta_0VwMdXC7cb ← X | ✓ → image_2022-12-09_001606556

I’m not sure if you heard of the Blur Background for the Pause Menu, but that’s the type of thing I’m looking for just instead of blurring the Custom Cursor the transparency of the it would be gone.

Source Code of the Custom Cursor if it helps (It's inside of a GUI)

-- // Services

-- External services
local userInputService = game:GetService("UserInputService")
local tweenService = game:GetService("TweenService")
local runService = game:GetService("RunService")

-- Internal services
local playersService = game:GetService("Players")

-- // Variables

-- Player variables
local player = playersService.LocalPlayer
local mouse = player:GetMouse()

local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:FindFirstChild("Humanoid")

local camera = workspace.CurrentCamera

-- UI variables
local cursorUI = script.Parent
local cursor = cursorUI:WaitForChild("Cursor")
local clicked = cursor:WaitForChild("Clicked")

-- Values
local target = nil

-- // Functions
userInputService.MouseIconEnabled = false

local function tweenCursor(state)
    
    local tween = nil
    
    if state == true then
        
        tween = tweenService:Create(cursor, TweenInfo.new(0.25, Enum.EasingStyle.Quad), {
            ImageColor3 = Color3.fromRGB(255, 82, 82),
            Size = UDim2.new(0.03, 0, 0.03, 0)
        })
        
    elseif state == false then
        
        tween = tweenService:Create(cursor, TweenInfo.new(0.25, Enum.EasingStyle.Quad), {
            ImageColor3 = Color3.fromRGB(255, 255, 255),
            Size = UDim2.new(0.02, 0, 0.02, 0)
        })
        
    end
    
    tween:Play()
    
    spawn(function()
        tween.Completed:Wait()
        tween:Destroy()
    end)
    
end

local function clickedEvent()
	clicked:TweenSize(UDim2.fromScale(1, 1), Enum.EasingDirection.Out, Enum.EasingStyle.Quint, 0.25, true, nil)
	
	local tween = tweenService:Create(clicked, TweenInfo.new(0.25, Enum.EasingStyle.Quad), {BackgroundTransparency = 1})
	tween:Play()
	
	spawn(function()
		tween.Completed:Wait()
		tween:Destroy()
		
		clicked.Size = UDim2.fromScale(0, 0)
		clicked.BackgroundTransparency = 0
	end)
end

local function updateCursor()
    
    cursor.Position = UDim2.new(0, mouse.X, 0, mouse.Y)
    
    target = mouse.Target
    
    if target ~= nil and target:FindFirstChildOfClass("ClickDetector") then
        local click = target:FindFirstChildOfClass("ClickDetector")
        
        if (character.HumanoidRootPart.Position - target.Position).Magnitude < click.MaxActivationDistance then
            tweenCursor(true)
        else
            tweenCursor(false)
        end
    else
        tweenCursor(false)
    end

end

-- // Connections
mouse.Button1Down:Connect(function()
	if target ~= nil and target:FindFirstChild("ClickDetector") then
		print("Clicked click detector")
		
		clickedEvent()
	end
end)

runService.RenderStepped:Connect(updateCursor)
1 Like

GuiService.MenuOpened or MenuClosed has a delay and you cant fix it

-- // Services

-- External services
local userInputService = game:GetService("UserInputService")
local tweenService = game:GetService("TweenService")
local guiService = game:GetService("GuiService")
local runService = game:GetService("RunService")

-- Internal services
local playersService = game:GetService("Players")

-- // Variables

-- Player variables
local player = playersService.LocalPlayer
local mouse = player:GetMouse()

local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:FindFirstChild("Humanoid")

local camera = workspace.CurrentCamera

-- UI variables
local cursorUI = script.Parent
local cursor = cursorUI:WaitForChild("Cursor")
local clicked = cursor:WaitForChild("Clicked")

-- Values
local target = nil

-- // Functions
userInputService.MouseIconEnabled = false

local function tweenCursor(state)

	local tween = nil

	if state == true then

		tween = tweenService:Create(cursor, TweenInfo.new(0.25, Enum.EasingStyle.Quad), {
			ImageColor3 = Color3.fromRGB(255, 82, 82),
			Size = UDim2.new(0.03, 0, 0.03, 0)
		})

	elseif state == false then

		tween = tweenService:Create(cursor, TweenInfo.new(0.25, Enum.EasingStyle.Quad), {
			ImageColor3 = Color3.fromRGB(255, 255, 255),
			Size = UDim2.new(0.02, 0, 0.02, 0)
		})

	end

	tween:Play()

	spawn(function()
		tween.Completed:Wait()
		tween:Destroy()
	end)

end

local function clickedEvent()
	clicked:TweenSize(UDim2.fromScale(1, 1), Enum.EasingDirection.Out, Enum.EasingStyle.Quint, 0.25, true, nil)

	local tween = tweenService:Create(clicked, TweenInfo.new(0.25, Enum.EasingStyle.Quad), {BackgroundTransparency = 1})
	tween:Play()

	spawn(function()
		tween.Completed:Wait()
		tween:Destroy()

		clicked.Size = UDim2.fromScale(0, 0)
		clicked.BackgroundTransparency = 0
	end)
end

local function updateCursor()

	cursor.Position = UDim2.new(0, mouse.X, 0, mouse.Y)

	target = mouse.Target

	if target ~= nil and target:FindFirstChildOfClass("ClickDetector") then
		local click = target:FindFirstChildOfClass("ClickDetector")

		if (character.HumanoidRootPart.Position - target.Position).Magnitude < click.MaxActivationDistance then
			tweenCursor(true)
		else
			tweenCursor(false)
		end
	else
		tweenCursor(false)
	end

end

local function menuOpened()
	cursorUI.Enabled = false
end

local function menuClosed()
	cursorUI.Enabled = true
end

-- // Connections
mouse.Button1Down:Connect(function()
	if target ~= nil and target:FindFirstChild("ClickDetector") then
		print("Clicked click detector")

		clickedEvent()
	end
end)

runService.RenderStepped:Connect(updateCursor)
guiService.MenuOpened:Connect(menuOpened)
guiService.MenuClosed:Connect(menuClosed)
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.