Custom mouse cursor with custom click detector cursor

I already have this script, but it doesn’t work

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local cursorGui = script.Parent

-- Hide default cursor
mouse.Icon = "rbxasset://textures\\ArrowCursor.png"

-- Update cursor position
mouse.Move:Connect(function()
	cursorGui.ImageLabel.Position = UDim2.new(0, mouse.X, 0, mouse.Y)
end)

-- Show custom cursor
cursorGui.ImageLabel.Visible = true

-- Hide custom click detector cursor initially
cursorGui.CustomClickDetectorCursor.Visible = false

-- Show custom click detector cursor on mouse click
mouse.Button1Down:Connect(function()
	cursorGui.ImageLabel.Visible = false
	cursorGui.CustomClickDetectorCursor.Visible = true
end)

-- Hide custom click detector cursor on mouse release
mouse.Button1Up:Connect(function()
	cursorGui.ImageLabel.Visible = true
	cursorGui.CustomClickDetectorCursor.Visible = false
end)

Does anyone know what I can do to fix this?

3 Likes

Can’t you just change mouse.Icon in the Button1Down & Button1Up event?

mouse.Icon = "rbxasset://textures\\ArrowCursor.png" -- Set new default cursor

mouse.Button1Down:Connect(function()
    mouse.Icon = "[CUSTOM CURSOR HERE]"
end)

mouse.Button1Up:Connect(function()
    mouse.Icon = "rbxasset://textures\\ArrowCursor.png"
end)
1 Like