PcoWSkbVqDnWTu_dm2ix

Mouse Pointer Control

Mouse Pointer Control

5 min

This article explains how the mouse pointer behavior can be customized.

Set Mouse Icon

Changing the icon of a player’s mouse can be done in a LocalScript by setting its Mouse/Icon|Icon to a custom Roblox asset ID:

Note that since the icon is set in a LocalScript, each player can have a different icon, or can have an icon appear in certain situations like when an ability is recharging or the mouse is hovering over a hostile target.

Hide Mouse Icon

The mouse icon’s visibility can be toggled on and off via UserInputService/MouseIconEnabled within a LocalScript. For example, the following code will switch the mouse from visible to invisible and back every two seconds:

Lock Mouse Position

The mouse position can be locked to the screen using UserInputService/MouseBehavior with a value of enum/MouseBehavior|Enum.MouseBehavior.LockCurrentPosition or enum/MouseBehavior|Enum.MouseBehavior.LockCenter. Setting this property back to enum/MouseBehavior|Enum.MouseBehavior.Default will unlock the mouse.

Note that if the mouse is locked, UserInputService/InputChanged will still fire when the player moves the mouse, passing in the distance the mouse has moved.

Tags:
  • input
  • mouse
  • ui
  • gameplay