Having issues while trying to change the Mouse Icon in my Roblox Game

Hello, I have this problem every time I try to change the mouse icon in my game. This problem has happened to me in several games I’ve made before and I still haven’t found a solution.

The problem is that the mouse icon is only changed in the Roblox Studio play test, but is not changed in the game itself published on Roblox. The truth is I don’t know why this happens. And in the output it does not show any errors.

I have tried different things such as: putting the script in different places, using my own images, and modifying the scripts. But it doesn’t work anyway.

Here are the two scripts I used:

Script 1:

local player = game.Players.LocalPlayer

local Mouse = player:GetMouse()

if player then
    Mouse.Icon = "rbxassetid://15722065980"
end

Script 2:

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

local function setMouseIcon()
	mouse.Icon = "rbxassetid://15722065980"
	print("Mouse icon set to:", mouse.Icon)
end

player.CharacterAdded:Connect(function(character)
	wait(1) -- Give it a moment to fully load
	setMouseIcon()
end)

if player.Character then
	setMouseIcon()
end

If anyone has an answer or can help me, feel free to reply in this topic.
Thank you for reading :slight_smile:

3 Likes

Try using UserInputService like this.

Script 1:

local uis = game:GetService("UserInputService")

local player = game.Players.LocalPlayer

--local Mouse = player:GetMouse()

if player then
    uis.MouseIcon = "rbxassetid://15722065980"
end

Script 2

local uis = game:GetService("UserInputService")

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

local function setMouseIcon()
uis.MouseIcon = "rbxassetid://15722065980"
	print("Mouse icon set to:", uis.MouseIcon)
end

player.CharacterAdded:Connect(function(character)
	wait(1) -- Give it a moment to fully load
	setMouseIcon()
end)

if player.Character then
	setMouseIcon()
end
3 Likes

I’m still having the same error, but thanks for trying to help me.

No problem. Where’s the script located and does it show any errors in the output?

1 Like

The problem with the image asset you’re using is that it is around 400x400 pixels in size, mostly consisting of transparent space. There’s now a limit of 256x256 for the max cursor size, because of security concerns. I’d suggest cropping this image and reuploading it.

(That’s why you see it in studio and not in-game)

1 Like

The script is located inside StarterPlayerScripts and it does not shows any errors in the output.

Now it works in-game! Thank you :slight_smile:

1 Like