A clean mouse library using up-to-date input APIs. Only works on the client.
This library returns a Mouse
object which can be used similar to the official deprecated Mouse
object.
local Mouse = require(script.RbxMouse)
Certain features will only start running if used (e.g. Mouse.CFrame
is indexed).
This Mouse
object has a lot of similar properties. The CFrame and Target properties will not be up
The 2D position of the mouse.
The 3D position and direction of the mouse (see Configuration & Mouse:SetRayDistance()
).
The part the mouse is over (see Configuration & Mouse:SetRayDistance()
).
The Mouse
object contains signals that can be treated exactly like RbxScriptSignals
.
There are three signals for every mouse button:
- Button
X
Down - Button
X
Up - Button
X
Click
The ButtonXClick
event will fire if ButtonXUp
is fired less than or exactly 0.5* seconds after ButtonXDown
(see Configuration & Mouse:SetClickThreshold()
).
Example usage:
Mouse.Button1Down:Connect(function()
print("Left mouse button is down!")
end)
local Button3ClickConnection = Mouse.Button3Click:Connect(function()
print("Middle mouse button has been clicked!")
end)
Mouse.Button2Up:Wait()
Button3ClickConnection:Disconnect()
The Mouse
object has a number of methods for different features.
Disconnects the Mouse
object from all input signals. Useful if you want to disable mouse input detection.
Reconnects the Mouse
object to all input signals.
Hides the mouse. Only needs to be called once.
Shows the mouse. Only needs to be called once.
The threshold for firing a click event between mouse down and up events. Defaults to 0.5
.
The limit of mouse CFrame and Target detection. Defaults to 1000
.
Child objects that can be indexed using Mouse.ChildName
.
Object that holds four methods for manipulating the filter for the Mouse.Target
property:
-
array TargetFilter:Get ()
-
void TargetFilter:Set ( <array<Instance>/Instance/nil> IgnoreDescendantsInstance )
-
void TargetFilter:Add ( <Instance> IgnoreDescendantsInstance )
-
void TargetFilter:Remove ( <Instance> IgnoreDescendantsInstance )
Object that holds two methods for manipulating the mouse icon:
- void/string Icon:Get ()
- void Icon:Set ( <int/string> AssetId )
Must be edited manually.
The threshold for firing a click event between mouse down and up events. Defaults to 0.5
.
The limit of mouse CFrame and Target detection. Defaults to 1000
.