MouseService: An All In One Mouse!

Let’s be honest. The Roblox mouse is trash. With so many things unaccounted for, developers often get code like this:

local IgnoreInsetPosition = game:GetService("UserInputService"):GetMouseLocation()
  • which is not ideal for a platform our size.

This is why I created MouseService. With MouseService, you can do the following all in one module:

  • Get GUI inset
  • Get viewport & screen size in one (screen size is accounting for GUI inset)
  • Set a custom cursor
  • Set cursor enabled
  • Custom raycasts!
    This includes…
  • Custom ray magnitude (to control the range of your Mouse.Hit; no more checking if objects are in range!)
  • Custom RaycastFilterType
  • Custom and Multiple FilterDescendantInstances
  • Choose to account for or ignore GUI inset when raycasting (useful for cross-platform support)

Here’s how you would use this module:

local MouseService = require(game:GetService("ReplicatedStorage").Modules.MouseService)

I’d recommend you read the module, it’s pretty simple!

Take a copy for yourself from the Roblox toolbox!

Feel free to make any suggestions for future updates.

8 Likes