Make a custom cursor

Hello! I am trying to make a custom cursor for my game, however I need to make it change to different cursors when I hover over things. Like text boxes or buttons.
How do I do this?

Current Script:

local userInputService = game:GetService("UserInputService")
local starterGui = game:GetService("StarterGui")

local cursorGui = script.Parent:WaitForChild("Cursor")
local cursorImage = cursorGui.Cursor

userInputService.MouseIconEnabled = false
starterGui:SetCoreGuiEnabled("All", false)

local normalCursor = "rbxassetid://7025168168"
local hoverCursor = "rbxassetid://7025167191"
local textCursor = "rbxassetid://79572790"

while wait() do
	if userInputService.KeyboardEnabled then
		script.Parent.Cursor.Enabled = true
		local mouseLocation = userInputService:GetMouseLocation()
		cursorImage.Position = UDim2.fromOffset(mouseLocation.X, mouseLocation.Y)
	else
		script.Parent.Cursor.Enabled = false
	end
end
1 Like
local mouse = game.Players.LocalPlayer:GetMouse()

UIObject.MouseEnter:Connect(function()
	mouse.Icon = hoverCursor
end)
UIObject.MouseLeave:Connect(function()
	mouse.Icon = normalCursor
end)

Where UIObject is a reference to something like a text button.

2 Likes

Hang on, I found an idea anyways. Thanks for trying to help!

Hey, I’ve wanted to do this (though I wasn’t successful). Do you mind posting how you achieved it, if you do? Thanks, and good luck!

Maybe I will. No guaranties tho. :stuck_out_tongue:

1 Like

No clue why he’s gatekeeping it, but I’m fairly sure @NyrionDev’s solution works well. If it doesn’t though, just tell me and I’ll post another solution.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.