Mouse.Icon overrides CursorIcon from ClickDetector

So yeah i am using a custom mouse icon doing

local mouse = game:GetService("Players").LocalPlayer:GetMouse()
mouse.Icon = "http://www.roblox.com/asset?id="

and basically i want when i hover the mouse over a click detector to change the mouse icon to that 1 but it doesn’t work. In studio when i move my mouse out of the game window in play testing then it changes to that 1…

Any ideas??

1 Like

There is a string property in the ClickDetector called mouseicon. Try changing that to the Mouse.Icon decal.

You can use .MouseHoverEnter and .MouseHoverLeave to achieve this. It would look like this:

local mouseIcon = "" --mouse icon
local clickIcon = "" --click detector icon

local clickDetector = workspace.Part.ClickDetector --click detector reference

local mouse = game.Players.LocalPlayer:GetMouse()

mouse.Icon = mouseIcon

clickDetector.MouseHoverEnter:Connect(function()
       mouse.Icon = clickIcon
end)

clickDetector.MouseHoverLeave:Connect(function()
       mouse.Icon = mouseIcon
end)

You could set up a table with all the click detectors and loop through them calling this process for each of them.

4 Likes

I don’t know if you’ll respond but it’s worth a try!

local ButtonTable = {}  -- Table filled with click detectors of each of the buttons.

for i, v in pairs(workspace:GetDescendants()) do
	--v.MouseClick:Connect(function()
	if v:IsA("ClickDetector") then 
		table.insert(ButtonTable,i,v) --Inserts the ClickDetectors into ButtonTable
		print(ButtonTable[i])
		print("PRINTED")
	end
end

local mouseIcon = "5207095807" --mouse icon
local clickIcon = "5207096357" --click detector icon

local clickDetector = ButtonTable --click detector reference

local mouse = game.Players.LocalPlayer:GetMouse()

mouse.Icon = mouseIcon

clickDetector.MouseHoverEnter:Connect(function()
	mouse.Icon = clickIcon
end)

clickDetector.MouseHoverLeave:Connect(function()
	mouse.Icon = mouseIcon
end)

Tried to do what you said but cannot figure out how to make it work? Would appreciate if you could help me understand how I would make this work, many thanks.