Custom cursor set help

Good afternoon,

I am currently trying to add custom cursors to my game for all the different cursor states.
Roblox already has the types of cursors listed here:

https://create.roblox.com/docs/reference/engine/classes/Mouse#IconContent

However, there doesnt seem to be any property I can use to change the cursor icon for anything besides the basic pointer cursor:

local mouse = player:GetMouse()
mouse.Icon = "rbxassetid://128332868002532"

How can I change the icons for all the other cursors? i.e. Pointer, Open hand, Closed Hand, etc. (examples below)
KriegCursor
KriegCursor_Closed
KriegCursor_Open

Many thanks,
bigclaphead

You should use UserInputService for new work, player:GetMouse() is deprecated.

To set the icon with UserInputService do UserInputService.MouseIcon = "rbxassetid://..."

You can detect whether interface is hovered by adding UserInputService.InputChanged connection, it provides gameProcessedEvent boolean parameter, which you can check and change the mouse icon accordingly. Or if you have custom hover/drag logic, you’ll need to hook the system with mouse icon.

2 Likes

As @LvieReal said, use UserInputService.MouseIcon over player:GetMouse().Icon

There is no way to change other default Icons (Hover, I-beam) EXCEPT for Shiftlock icon (Which is a bit tricky, there are free models that do this, however.)

1 Like

Thank you for your guidance!

I probably couldve done this more effectively, but this works:

local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")

-- Get Nessecary UI elements
local player = Players.LocalPlayer
local PlayerGui = player:WaitForChild("PlayerGui")
local MouseGUI = PlayerGui:WaitForChild("MouseGUI")
local MouseIcon = MouseGUI:WaitForChild("MouseIcon")

-- Get different pointers ( see above for reference ) 
local Pointer:ImageLabel = MouseIcon:WaitForChild("Pointer")
local Grab:ImageLabel    = MouseIcon:WaitForChild("Grab")
local Open:ImageLabel    = MouseIcon:WaitForChild("Open")

-- Setup States
local MouseHeld = false
local LastState = Pointer
local State = Pointer
State.Visible = true
 
-- If previous state visible, make it invisible and make the new state visibile.
local function MouseLogic()
 	if LastState~=State then
		State.Visible = true
		LastState.Visible = false
	end
end

-- Move cursor aswell as determine the state of the mouse 
local function Input(input, processed)
	
-- Move Cursor
	MouseIcon.Position = UDim2.fromOffset(UserInputService:GetMouseLocation().X, UserInputService:GetMouseLocation().Y)

-- Determine if mouse is held
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		if MouseHeld==false then MouseHeld = true else MouseHeld = false end
	end
	
-- If mouse is held, and state is already Grab, then do not change state until not holding mouse
	if State==Grab and MouseHeld==true then return end

-- State Logic:
--    Processed tells me when the cursor is hovering over a GUI/Prompt/ClickDetector 
--    MouseHeld tells me if the mouse is held 
	LastState=State
	if State~=Open and MouseHeld == false and processed == true then
		State=Open
	elseif State~=Grab and MouseHeld == true then
		State=Grab
	elseif State~=Pointer and processed == false then
		State=Pointer
	end

MouseLogic()

end

UserInputService.InputBegan:Connect(Input)
UserInputService.InputChanged:Connect(Input)
UserInputService.InputEnded:Connect(Input)

UserInputService.MouseIconEnabled=false

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