Custom mouse icons not working

Hello! I am experiencing a bug/error where I can’t set a custom crosshair to the player’s mouse, how can I fix this? The mouse icon is set after loading, but then resets after the mouse moves, I’ve tried using loops to set it but those crash Roblox Studio.

	if equipped == true then
		script.Parent.Remotes.PlayEquipAnimation:FireServer(player)
		local mouse = player:GetMouse()
		mouse.Icon = script.Parent.Configuration.CrossHairId.Value
	end```
2 Likes

You forgot to add the wait() so your game crashes
For loops you have to do:

while true do
    wait()
	if equipped == true then
		script.Parent.Remotes.PlayEquipAnimation:FireServer(player)
		local mouse = player:GetMouse()
		mouse.Icon = script.Parent.Configuration.CrossHairId.Value
	end
end
1 Like

If you could show more of the script then that could help get a better view of what’s going on.

If you’re trying to use loops, you then need to do one of the following:
1- you said looping was crashing ROBLOX right? Then you’re probably using while true do, which crashes ROBLOX. Instead, you could use while wait() do, which will not crash the game.
2- you could do something like repeat wait() until not equipped - not sure if that’d work in your case, but give it a try, might work for you.

1 Like

My gun animations jitter and shake and my gun turns into a pogo stick

I’ll try this, but I have low hopes for this too.

Separate the 2 scripts so you just do this on its own:

coroutine.wrap(function()
	while true do
		wait()
		if equipped == true then
			local mouse = player:GetMouse()
			mouse.Icon = script.Parent.Configuration.CrossHairId.Value
		end
	end
end)();

then just put the animation part under or over it.

1 Like

Thank you so much! It finally works, although I wish it would be a simple mouse.Icon this is all I got. Thank you once again