Mobile Mouse Module - Easy Mobile Support!

The goal of this module is to replace LocalPlayer:GetMouse() painlessly with a module that uses newer features like UserInputService, Raycasts and RaycastParams while adding mobile support for click inputs, and keeping the simplicity of Player:GetMouse().
It’s as simple as replacing LocalPlayer:GetMouse() with require(X.Mouse):GetMouse()

The module containts plenty of settings to either, make the module as close as possible to Player:GetMouse(), to update older scripts, or settings to make it more usable, such as getting rid of the GuiIinset non sense, or allowing mouse click events to fire even when GameProssesedEvent is true, by sending GameProssesedEvent as an argument instead.

The mobile support is done through a “fake mouse” that takes the form of a crosshair. Click to move the crosshair, double click to activate the click events. The crosshair is considered as being the mouse cursor by the module.
Mobile support can easily be tested by setting the EMULATE_TOUCH variable to true


This is the implementation of the module in my game

The mobile cursor cannot fire the middle mouse button events or the right mouse button events
The detection to register click is only based on the time between two clicks. I would like to also make it consider the distance between the two clicks.

All the info to get the module up and running is in the READ_ME script of the model

Marketplace link for the module
uncopylocked place with example scripts


If you encounter any bug with the module, please tell me!

I would like to improve the module to allow different settings for every “mouse instance” returned by :GetMouse(), and also changing the structure to use an OOP structure instead, I should probably learn how to use OOP…
Controller support is also something that would be a great addition to the module. I do not own a controller so, can’t really do that.

I hope this module can be useful for anyone of you. I initially made it for my own game, but I wanted to share it as well

25 Likes

A way to implement right clicking could be to detect when the finger is held down for an amount of time as opposed to just being tapped. This is what most Remote Desktop applications do, as well as windows touchscreen mode, so it should be pretty intuitive.

5 Likes

I get the error ReplicatedStorage.Mouse:556: attempt to call a nil value - Client - Mouse:556, and I doing it wrong because for me the setup wasn’t really clear

1 Like

That would happen if you call a property of the mouse that doesn’t exist.

If you’d like, I could make an uncopylocked place that contains the mouse module and a local script that requires it and stuff

2 Likes

That, would be great but I figured it out. It would be helpful to others with the same issue

1 Like

Done!

1 Like