PlayerMouse - A Modern Replacement for the legacy Mouse object

I wrote this module 2 days ago and put it on Github as a public repository. I’m posting this here incase anyone would find a use for it (because I certainly did), it can integrate easily with existing mouse code and is modernized, with more functionality & more customizable.

The source code is distributed for free under the MIT License, which in short let’s you use it for whatever purpose free of any warranty or gurantee.

There’s also different modules at the RobloxModules github organization if you want to see what’s there. The collection will expand, I just don’t know when I’ll add more modules.

Do you want to get a module script uploaded to the RobloxModules github organization? Let me know! Make sure to provide the module, and acknowledge it’ll be distributed for free under the MIT License. When your module is uploaded to the github organization, you’ll be credited.

Example of how it can be used

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local PlayerMouse = require(ReplicatedStorage.PlayerMouse)

local player = Players.LocalPlayer
local mouse = PlayerMouse.New()

mouse.Button2Up:Connect(function()
	print("Button2Up")
end)

mouse.WheelForward:Connect(function(...)
	print("Scroll wheel forward", ...)
end)

mouse.WheelBackward:Connect(function(...)
	print("Scroll wheel backward", ...)
end)

This is my first post here! Let me know what I can do differently to be more helpful!

4 Likes

Updated to remove the Player parameter after some consideration
It’s a client-only module, it could’ve gotten the player with the code below, so why include an unnecessary parameter to get the player?

local Players = game:GetService("Player")
local player = Players.LocalPlayer