PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

MouseIconEnabled

UserInputService

bool

This property determines whether the Mouse|Mouse’s icon is visible When true the mouse’s icon is visible, when false it is not.

For example, the code snippet below hides the mouse’s icon.

local userInputService = game:GetService("UserInputService")

userInputService.MouseIconEnabled = false

As UserInputService is client-side only, this property can only be used in a LocalScript.


Code Samples


Hide Mouse During Keyboard Input

This example hides the mouse icon while the player beings using their keyboard, such as to chat or enter text into a TextBox. The mouse icon reappears when the user resumes mouse input.

This uses the UserInputType/LastInputType|LastInputType event to determine when the user begins keyboard input and mouse input - based on the value of the Enum/UserInputType/lastInputType argument.

In order for this example to work as expected, it should be placed in a LocalScript.

local UserInputService = game:GetService("UserInputService")

local mouseInput =
{
	Enum.UserInputType.MouseButton1,
	Enum.UserInputType.MouseButton2,
	Enum.UserInputType.MouseButton3,
	Enum.UserInputType.MouseMovement,
	Enum.UserInputType.MouseWheel	
}

local keyboard = Enum.UserInputType.Keyboard

local function ToggleMouse(lastInputType)
	if lastInputType == keyboard then
		UserInputService.MouseIconEnabled = false
		return
	end
	
	for i, mouse in pairs (mouseInput) do
		if lastInputType == mouse then
			UserInputService.MouseIconEnabled = true
			return
		end
	end
end

UserInputService.LastInputTypeChanged:Connect(ToggleMouse)