Mouse.Icon Not Changing

  1. What do you want to achieve? I am trying to change the mouse’s icon.

  2. What is the issue? Whenever I try to change it, it just stays as the default.

  3. What solutions have you tried so far? I am trying to use mouse.Icon

Here is the code:

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

mouse.Icon = "http://www.roblox.com/asset/?id=5923963876"

For some reason, it just stays the same. This script is a local script inside of PlayerGui. I am trying to play test in studio.

4 Likes

It works fine for me. Do you have any other scripts which interact with this script or the mouse icon in any way?

The script isn’t disabled or anything?

1 Like

From the looks of it, I have no clue what’s happening with your image, make sure your image is correctly imported into Roblox.

Also are you changing this directly when the game starts or when something happens?

2 Likes

Try this;

mouse.Icon = "rbxassetid://5923963876"

The link you’re using returns a 404 error.

1 Like

I wrote a LocalScript for you.

1. local Players = game:GetService("Players")
2. local mouse = Players.LocalPlayer:GetMouse()
3. mouse.Icon = "rbxassetid://5923963876"

Yes, if something doesn’t work, check the mouse icon itself (whether the image is blocked or check the correct id)

2 Likes
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

mouse.Icon = "rbxassetid://5923963876"
1 Like

No, it’s not disabled.


I think the problem is with Studio, not the script. I’m going to try to reinstall.

1 Like

It changes directly when the game starts. The code I have above is the only code in the script.

Also, it looks like the image got corrupted or something.
What I uploaded it as:
MouseClick
(It might be hard to see, it’s a white circle)

It looks weird in Roblox, tho → https://www.roblox.com/library/5923963876

2 Likes

@0ssm4n, @xPuff_le @WEcompany
Thank you, but those ideas don’t seem to be working. I’m starting to wonder if the problem is with my version of studio rather than the script. It may work while playing in Roblox rather than Play-Testing

2 Likes

You need to put the image id on a decal which will reset the stuff then copy that id the decal gave

2 Likes

Maybe make sure the mouse exists before changing it? I noticed that sometimes the Mouse doesn’t really get replicated until the initial loading stage (invisible mouse, not replicated).

game.Loaded:Wait()
game.Players.LocalPlayer:GetMouse().Icon = "rbxassetid://5923963876"

The same issue happens with LocalPlayer with Replication sometimes.

local Player = game.Players.LocalPlayer or game.Players:GetPropertyChangedSignal("LocalPlayer"):Wait()
Player:GetMouse().Icon = "rbxassetid://5923963876"

What may be happening is Roblox automatically switching the mouse icon when it’s hovering over a GuiElement.

Sadly, Roblox will change back to the default icon instead of using the last mouse icon. You’ll have to either set it constantly or listen when it changes to a value that isn’t your custom icon.

On a side-note, you should use the rbxassetid protocol instead of using a direct link to keep your code clean!

3 Likes
local ID = "rbxassetid://5923963876"
local plr = game:GetService("Players").LocalPlayer
local mouse = plr:GetMouse()

repeat wait() until game:IsLoaded()
mouse.Icon = ID

Let me know if this works.

If you want a reset one just like @jrelvas said, do this:

local ID = "rbxassetid://5923963876"
local plr = game:GetService("Players").LocalPlayer
local mouse = plr:GetMouse()

repeat wait() until game:IsLoaded()

while true do
   mouse.Icon = ID
end
  • Edit: I forgot to add .LocalPlayer. Oops!
5 Likes

Try putting the script in StarterPlayerScripts.

It is not working for me also with most of the roblox Ids, no matter if I use rbxasset://SystemCursors/Cross, rbxassetid or any other kind of url.
The problem appears when I set the Icon from the beginning of the game, I solve it adding a wait() before setting the icon.
Also this shouldnt happen and I’m pretty sure is a bug that no one wants to fix. Even the example here: Mouse | Roblox Creator Documentation is not working without the wait().

3 Likes

I had to change the actual image of the icon because either the image that I was using before was corrupted or taken down, try this if you’re having problems. (MAKE SURE TO FIND YOUR IMAGES IN STUDIO FOR THIS)

2 Likes

Have you tried:

local userInputService = game:GetService("UserInputService")
userInputService.MouseIcon = "rbxassetid://5923963876"

or

local mouse = game.Players.LocalPlayer:GetMouse()
mouse.Icon = 'rbxassetid://5923963876'

I had the same issue. I fixed it by changing the link to
"http://www.roblox.com/asset/?id=YourID" instead of "rbxassetid://YourID"
and using the UserInputService

local userInputService = game:GetService("UserInputService")
userInputService.MouseIcon = "http://www.roblox.com/asset/?id=YourID"
1 Like