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 gameProcessedEventboolean 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.
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.)
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