Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can I change the mouse property on certain events?

I know you can change the player's mouse with this:

game.Players.LocalPlayer:GetMouse().Icon = "rbxassetid://123456" --etc.

but if there is an occasion such as when hovering over a ClickDetector or a TextButton, I want to change it to go with a new enabled mouse cursor. How would I be able to do that?

I don't even need a script, if you could just point me to some resources, that'd be great!

1 answer

✓ Accepted answer

You could have a LocalScript that detects when the ClickDetector's MouseHoverEnter and MouseHoverLeave events trigger, and change the player's mouse through that.

As an example (untested):

local mouse = game.Players.LocalPlayer:GetMouse() --get the player's mouse
local defaultIcon = mouse.Icon --store the default icon into a variable

workspace.YourClickDetector.MouseHoverEnter:connect(function()
    mouse.Icon = "hover icon" --when YourClickDetector in workspace is entered, set the cursor to "hover icon"
end)

workspace.YourClickDetector.MouseHoverLeave:connect(function()
    mouse.Icon = defaultIcon --when YourClickDetector in workspace is left, set the cursor back to the default
end)

2 comments

0

Is there a way for this if I have multiple ClickDetectors?

0

Yes, you can just connect all of them to the function to change icons, though you should have one function instead of the inline functions I provided in that scenario.

This discussion is preserved as it was. New answers, comments, and votes are closed.