Help with custom cursor icon

I am trying to make a custom cursor by making an imagelabel follow the actual cursor. To add onto this, I also want to allow it to show clickdetector icons from the property in the actual clickdetector. When i hover over a clickdetector with my code, it gives me this error:
Players.Max_thenoob6284.PlayerGui.MouseIcon.ImageLabel.UpdateMouse:8: attempt to index string with 'Position'
Here is the code and Hierarchy for my custom cursor.

local UIS = game:GetService("UserInputService")
local GS = game:GetService("GuiService")
local RS = game:GetService('RunService')
local Mouse = game.Players.LocalPlayer:GetMouse()
local image = script.Parent

RS.RenderStepped:Connect(function()
-- line below responsible for error
	image.Position = UDim2.new(0, Mouse.X, 0, Mouse.Y + GS:GetGuiInset().Y)
	if Mouse.Target and Mouse.Target:FindFirstChildOfClass("ClickDetector") then
		image = Mouse.Target:FindFirstChildOfClass("ClickDetector").CursorIcon
	end
end)


UIS.MouseIconEnabled = false

image

1 Like

There’s a much easier way to set a custom cursor icon - use the Mouse.Icon property.

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

mouse.Icon = "rbxassetid://ID_HERE"

--you could also do "http://www.roblox.com/asset/?id=ID_HERE"
1 Like

ImageLabels are more customizable, and I need my cursor to have a resampling mode that looks pixelated. this is simply a workaround for what I need.

I’ve also noticed a bug with the mouse icon that makes the cursor move by a pixel whenever I click. This is noticeable because my game is in First Person.

I think the GetGuiInset().Y isn’t returning just a Number. Maybe try removing it first and see if it works then then we go from there I’m not in studio rn though.

that is not the issue. it still shows the error after removing that. the line is simply to account for the topbar that offsets the mouse position variables.

bumping this so i can see more responses tomorrow.

I am really hoping for more responses to this post.