A custom mouse module I made

Here is a custom mouse module I made which has almost all the useful features of the legacy mouse. No function call involved and the good thing is that the values aren’t updated every frame or in a loop except for 2 which is reasonable.

I may plan to open source this module for anyone to use.
These are the current functions:

mouse.Origin, mouse.Hit, mouse.OnScroll, Mouse.Idle ,mouse.OnMove, mouse.TargetFilter, mouse.UnitRay, mouse.X, mouse.Y

local mouse = require(game:GetService("ReplicatedStorage").Shared.Mouse)

mouse.TargetFilter = workspace.Part

mouse.OnScroll:Connect(function()
	print("scrolling")
end)

mouse.LeftClick:Connect(function()
	print("left clicked")
end)

mouse.ScrollClick:Connect(function()
	print("scroll clicked")
end)

while wait(1) do
	print(mouse.Hit, mouse.Hit.Position, mouse.Origin, mouse.UnitRay, mouse.X, mouse.Y)
end
3 Likes

Are there any advantages to using your module as opposed to Roblox’s Mouse API or UserInputService?

The default Mouse is legacy and UserInputService supersedes it.

I like abstraction that layer on top of existing functionality, but we have to look at this from an unbiased perspective.

I can definitely see myself utilizing this if it had more to it. Right now, it’s a good replacement for the legacy mouse features; however it’s almost not feature-rich enough to warrant using it. Just yet.

For instance, you’ve done great in recreating some really handy properties that existed on the old mouse but not on the new user input service; however, to really sell it I’d love to see more functionality built off of this. Such as some custom methods that are annoying to script and people would rather just get your module for.

For example,

mouse:beginSelectionBox()
local coords = mouse:endSelectionBox()
local tableOfParts = mouse:getPartsInSelectionBox(coords)

Would be a cool addition and definitely make me wanna start using your module!

1 Like

Scripting support is for asking for help/questions related to scripting. This topic is obviously to show off the mouse module he made.

2 Likes

The module’s goal is to have functionality exactly like the Mouse which is legacy. I do plan on adding more functionalities to it.

This is a cool mouse module! It could probably help some people out!

Is there any update to this / alternatives?