Mouse Icon changes back to default

I use a script that changes player’s mouse icon

local mouse = game.Players.LocalPlayer:GetMouse()
Mouse_Icon = "rbxasset://textures/GunCursor.png"
mouse.Icon = Mouse_Icon

It does change when I join the game for a brief second, but then changes back to the default white cursor and stays that way.

There are no other scipts that interfere with mouse in any way. I have scripts that mess with the camera (just camera, not mouse), but even after disabling all of them, the issue still persists. The game is LockFirstPerson mode.

1 Like

I ran into this issue before, and it seems to be because Roblox sets the players mouse cursor during the Rendering step of the Task Scheduler.

  local mouse = game.Players.LocalPlayer:GetMouse()
  Mouse_Icon = "rbxasset://textures/GunCursor.png"
  mouse.Icon = Mouse_Icon

With this script currently, it will run before the Rendering Step and be overwritten by Roblox’s default mouse cursor. (Unless the Local Script is loaded slowly because of the player’s computer speed.)

So you will need to add a task.defer() to ensure the mouse cursor is set after Roblox sets their cursor.

task.defer(function()
    local mouse = game.Players.LocalPlayer:GetMouse()
    Mouse_Icon = "rbxasset://textures/GunCursor.png"
    mouse.Icon = Mouse_Icon
end)
2 Likes

Thank you, seems about right, marking as solution for now, will test later

Hey I know I’m a bit late but I’m also having the same issue, and I’ve tried this but it didn’t work. The mouse appears there for a second then back to the original mouse cursor. This is a local script under StarterPlayerScripts. The game is also in LockFirstPerson. Any ideas on how I could fix this?

3 Likes

There is a new method on doing this, Roblox has made a blogpost on this.

local UserInputService = game:GetService("UserInputService")
UserInputService.MouseIcon = "rbxassetid://assetidhere"
4 Likes