How to make my custom mouse cursor appear over topbar?

I couldnt get game.Players.LocalPlayer:GetMouse().Icon = “myid”
to work. So that led me to creating my own icon, by disabling the default icon and running a script that places an image label at the mouses position, all nested inside it’s own screengui.

The problem is that when I hover over the hamburger icon, on the top bar, it goes behind it.

This is not desired for obvious reasons.

What I tried was setting the display order of the screengui to 99999. But that didnt work. I looked on google and the forum for some information but. Well that’s why I’m here.

Anyone know what I should do?

I’m on mobile atm. Cant format that code

1 Like

If you’re talking about the default Roblox top bar, you can actually disable it.

game.StarterGui:SetTopbarTransparency(1)

should work.

The top bar is already disabled. It’s the hamburger menu chat and emotes buttons my cursor goes behind.

Developer Guis cannot be rendered on top of CoreGuis for security reasons. Regardless of what implementation you use, your custom mouse will always end up behind a CoreGui. There is no way to change this behaviour and requests to be able to do so will be denied.

That’s unfortunate. Any idea why the mouse.Icon isnt working for me? Also, does anyone know if custom icons are available for when the mouse is over a button?

1 Like

Hi!

I couldnt get game.Players.LocalPlayer:GetMouse().Icon = “myid”
to work.

What do you mean with this? Did the script throw an error? Remember that the code must be in a local script.

Also, does anyone know if custom icons are available for when the mouse is over a button?

There’s something that could work. Try setting the mouse icon to a new image after a GuiButton (TextButton, etc.) signals MouseEnter, and set back the original icon after it signals MouseLeave:

--this code should be in a local script
local player = game:GetPlayers().LocalPlayer
local ID = "" -- your mouse icon id number
local newID = "" -- the mouse icon id number, which will show when hovering over a gui button
local button = script.Parent --define the button

button.MouseEnter:Connect(function()
    player:GetMouse().Icon = "http://www.roblox.com/asset/?id=" .. newID
end)

button.MouseLeave:Connect(function()
    player:GetMouse().Icon = "http://www.roblox.com/asset/?id=" .. ID
end)

No errors, and yes it’s in a local script. It just wouldnt change.

The solution you provided me seems hacky, but if theres no other way I guess that’s worth a shot… provided I can get it to change first.

If the icon isn’t showing up at all set it to a image label than get the asset id back from it. Setting it to an image label will “convert” it.

Maybe I’m not ‘converting’ it correctly.

game.Players.LocalPlayer:GetMouse().Icon = repStorage.UIAssets.Cursor.Image;

but shouldn’t it be less trivial than this?

The api says to just use an asset id. I’d like more of an explanation, rather than just a fix if anyone knows…

So I placed it after a wait in my gamestart script, and it appeared as intended. I guess the core gui was overwriting it.

This doesn’t actually work for me. yes I’m sure I’ve set it up correctly. In another post it says that it probably wont work as intended; Which it doesn’t.

Has anyone successfully done this?

For any skeptics, here is the code in all its simplicity.

    local player = game.Players.LocalPlayer
    local ico = game:GetService("ReplicatedStorage").UIAssets.Cursor.Image;
    local button = script.Parent

    button.MouseEnter:Connect(function()
    	print ("Change")
        player:GetMouse().Icon = ico
    end)

    button.MouseLeave:Connect(function()
    	print ("Change back")
        player:GetMouse().Icon = ico
    end)

In another post I’ve read, a dev suggested using both methods; that is using a custom cursor when over a button, and reverting back to the original when not over a button. I’ll give that a shot.

That code couldn’t help you at all :sweat:
About setting the mouse icon, Roblox wiki states that

this property is overridden when the mouse is hovering over a GuiButton .

This means both functions MouseEnter and MouseLeave are useless in this case. I’m sorry I couldn’t help.
However, you can counter this behaviour by setting the gui button’s Active property to false. For some reason, you will still have the same problem when you click the button tough…

That’s alright :slight_smile: I appreciate the help none the less. You still pointed me in the right direction.