How would I make the mouse change when hovering over part with ClickDetector

I need help with making a mouse change when hovering over a ClickDetector. I’ve searched around, and only found MounseEnter, which only works for GUIs.

Could anyone point me in the right direction, or give me a snippet/example of code to get me started? I don’t have any idea what to use.

Thank you!

There are events inside ClickDetector called MouseHoverEnter and MouseHoverLeave.

What they do is pretty self-explanatory.

1 Like

I tried making it like this

click.MouseHoverEnter:Connect(function()
	mouse.Icon = "(my decal)"
end)

But nothing happens, do you know what’s wrong with it?
(obviously my decal is a real decal)

I also tried

if click.MouseHoverEnter then
	mouse.Icon = "(my decal)"
end

And it didn’t work, can you help me?

You can only change the mouse from a LocalScript. A LocalScript won’t run in the Workspace, so you couldn’t just put the script into the part.

You would have to put the code in a LocalScript in StarterPlayer.StarterPlayerScripts.

1 Like

Now, it doesn’t change the mouse at all.
(The ClickDetector is inside a part, inside a human, inside a folder.)

Script is located in StarterPlayerScripts.
Code:

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

click = game.Workspace.NPCs.Dummy.Click.ClickDetector


if click.MouseHoverEnter then
	mouse.Icon = "(my decal)"
end

You have to treat MouseHoverEnter like an event, so you need to write the function as

click.MouseHoverEnter:Connect(function()
    mouse.Icon = "(your decal)"
end)

like you did before.

1 Like

When I hover over the thing, the mouse disappears, instead of showing the decal, do you know why?
I can confirm that the decal is indeed working, but it doesn’t show.

You probably formatted the Decal ID wrong. If you just put in the ID in a string, it won’t work.

If you put http://www.roblox.com/asset/?id= right before the ID in the string, it should work just fine.

For example, if the Decal ID was 1234567, you wouldn’t just put mouse.Icon = "1234567", you would put mouse.Icon = "http://www.roblox.com/asset/?id=1234567".

This is my code:

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

click = game.Workspace.NPCs.Dummy.Click.ClickDetector




click.MouseHoverEnter:Connect(function()
	mouse.Icon = "http://www.roblox.com/asset?id=(my id)"
end)

click.MouseHoverLeave:Connect(function()
	mouse.Icon = "http://www.roblox.com/asset?id=(my id)"
end)

Looks good to me. Is it working or not?

No, the mouse disappears on entry and exit.

I tried putting the decals on parts, and they worked just fine.
image

I think I need a screenshot of the raw code. The only thing I can think of now is if you put a space between http://www.roblox.com/asset?id= and your ID.

Woah woah woah. Y’all are doing the complicated way.
Just change the CursorIcon property to your image. Example:
image
it has to be formatted like: “rbxassetid://DECAL_ID_HERE”

Don’t use mouse.Icon, instead use the ClickDetector.CursorIcon property.

How would that work? Would I go like
ClickDetector.CursorIcon = "http://www.roblox.com/asset?id=(my id)

For your way, where would I find CursorIcon?

No, simply go to the properties menu for the ClickDetector, and change the ID of CursorIcon.

If my decal is too big, would I have to resize it, or is there a way to resize with a script or studio?