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

How to change the mouse icon when the mouse is hovering on a gui object?

So I've used roblox's Mouse.Icon property in order to change the icon, however a problem I've had is that when the mouse is hovered on a gui object the button returns to normal.

How can I make it change the icon regardless wherever the mouse is hovered on

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

2 answers

Use the MouseEnter and MouseLeave events of a GuiObject https://developer.roblox.com/en-us/api-reference/class/GuiObject

gui = game.Players.LocalPlayer.PlayerGui.yourGui

gui.MouseEnter:Connect(function()
	mouse.Icon = "http://www.roblox.com/asset/?id=id2"
end
gui.MouseLeave:Connect(function()
	mouse.Icon = "http://www.roblox.com/asset/?id=id1"
end

1 comment

0

Hey Abandion! Sadly this doesn't work because the icon of the mouse does not change while its hovered on a gui element

*Help For gfmf, not a answer change to Abandion's work.

Try changing the word 'yourGui' to your gui's name. And make sure its a local script.

gui = game.Players.LocalPlayer.PlayerGui.yourGui

gui.MouseEnter:Connect(function()
    mouse.Icon = "http://www.roblox.com/asset/?id=id2"
end
gui.MouseLeave:Connect(function()
    mouse.Icon = "http://www.roblox.com/asset/?id=id1"
end

This should work as long as the local script is inside startergui as a parent not child. (Not Inside a text label, etc) also change the id's to the decal ids. This may sound obvious but yea, most people forget these things.

1 comment

0

Hey! I've tried this and got the same result, when it's hovered on the gui it doesn't change, when you leave the gui it changes. The documentation for mouse.Icon says that it'll not take effect if it's hovered on a gui element.

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