Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How can I change the mouse property on certain events?

Asked by
itsJooJoo 195
8 years ago
Edited 8 years ago

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

Log in to vote
1
Answered by 8 years ago
Edited 8 years ago

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)
0
Is there a way for this if I have multiple ClickDetectors? itsJooJoo 195 — 8y
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. Kampfkarren 215 — 8y
Ad

Answer this question