Custom Cursor not changing

Hi!
I have a Custom Cursor script, and it wont change half the time.
What am I doing wrong?
Thanks!

-- CursorScriptv1.2
--[[

CURSOR V1.2


-Made smoother
- broke the fact it changes lol

-What else do you expect, this is a cursor script!
]]
local plr = game.Players.LocalPlayer
local runService = game:GetService("RunService")
local userInput = game:GetService("UserInputService")
local mouse = plr:GetMouse()
local mouseFr = script.Parent

local printDebug = false 

-- Functions --

function toggleNewMouse(enabled)
	if enabled then
		mouseFr.Visible = false
		mouse.Icon = "rbxasset://Cursors/KeyboardMouse/ArrowFarCursor.png"
		userInput.MouseIconEnabled = true
	else
		mouseFr.Visible = true
		mouse.Icon = ""
		userInput.MouseIconEnabled = false
	end
end

function updateMouse(x, y)
	mouseFr.Position = UDim2.new(0, x, 0, y) 

	if printDebug then
		print("Updated mouseFr position to " .. tostring(x) .. ", " .. tostring(y))
	end
end

function connectEvents(guiObject)
	if guiObject:IsA("GuiObject") then 
		guiObject.MouseEnter:Connect(function()
			if guiObject.Visible == true then
				if guiObject.Transparency ~= 1 then
					mouseFr.Image = "http://www.roblox.com/asset/?id=7027845989"
				end
			else
				mouseFr.Image = "http://www.roblox.com/asset/?id=7027810711"
			end
		end)

		guiObject.MouseLeave:Connect(function()
			mouseFr.Image = "http://www.roblox.com/asset/?id=7027810711"
		end)
	end
end

-- Main Logic --

toggleNewMouse(false)
plr.PlayerGui.DescendantAdded:Connect(connectEvents)

for _, descendant in pairs(plr.PlayerGui:GetDescendants()) do
	connectEvents(descendant)
end

runService.Stepped:Connect(function()
	updateMouse(mouse.X - 32, mouse.Y + 4) -- we negate 32 from X and add 4 to Y so the position for mouseFr is accurate
end)

Video:

Thanks for any help!

Hello, does anyone have an answer?

What could I be doing wrong? No errors are in the console.

You aren’t passing a true value to enabled. It’s setting the mouse icon to “”

That has nothing to do with that.

1 Like

Basically, it is setting the mouse icon property (which is a string) to empty.

Sorry, I didnt see the video or read the script fully. My bad. Try removing the else statement in the MouseEnter event. I believe its interfering with the other events.