RBX.lua.Mouse (Object)

From Legacy Roblox Wiki
Jump to navigationJump to search
Derived Classes
None
Local: This item should be used with a LocalScript in order to work as expected in online mode.

The Mouse object is the code interface for the computer mouse, including buttons and mouse position.

A Mouse object is not creatable, but can be obtained using the Selected event of HopperBins or the Equipped event of Tools. A Mouse object is only usable while the Player has the Tool or HopperBin selected. Once they are deselected, the Mouse's events will no longer be triggered and reading the properties will cause an error.

Example
script.Parent.Selected:connect(function(mouse) --have this LocalScript inside a HopperBin
	for i = 1, 10, 1 do --print the mouse's location 10 times
		wait(1)
		print(mouse.X, mouse.Y)
	end
end)
Clone( )
Returns Instance
Description: Returns a clone of the object and its children, unless its Archivable property is false. The clone will have the same properties as the original object and the same descendants (except those with an Archivable property set to false). The clone's Parent will be nil.
Member of: Instance
FindFirstChild( string name, bool recursive = false )
Returns Instance
Description: Returns the first child found with a name of name. Returns nil if no such child exists. If the optional recursive argument is true, will recursively descend the hierarchy while searching rather than only searching the immediate object.
Member of: Instance
GetChildren( )
Returns table
Description: Returns a read-only table of the object's children.
Member of: Instance
GetDebugId( int scopeLength )
Returns string
Description: Returns a coded string of the object's DebugId used internally by Roblox.
Member of: Instance
GetFullName( )
Returns String path to object
Description: Returns a string with a dot (.) character separating a path of object hierarchy excluding "game".
Member of: Instance
IsA( string className )
Returns bool
Description: Returns true if the Instance is that class or a subclass.
Member of: Instance
IsAncestorOf( Instance descendant )
Returns boolean is ancestor
Description: Returns true if the object is an ancestor of descendant.
Member of: Instance
IsDescendantOf( Instance ancestor )
Returns bool
Description: Returns true if the object is an descendant of ancestor.
Member of: Instance
Destroy( )
Returns nil
Description: Sets the Parent property to nil, locks the Parent property, disconnects all connections and calls Destroy() on all children.
Member of: Instance
ClearAllChildren( )
Returns nil
Description: Removes all descendants of the Instance, but leaves the Instance itself.
Member of: Instance
Hit
Property CFrame Hit
Description The position of where the mouse is pointing.
Member of Mouse
Icon
Property Content icon
Description Sets the mouse's icon.
Member of Mouse
Origin
Property CFrame Origin
Description CFrame of where the mouse pointer is when the mouse is unclicked.
Member of Mouse
Target
Property Instance Target
Description The object that the mouse is pointing to.
Member of Mouse
TargetFilter
Property Instance targetFilter
Description Allows parts to be disabled from the mouse's raycast functions.
Member of Mouse
TargetSurface
Property NormalId TargetSurface
Description Sets the particular surface to highlight.
Member of SurfaceSelection, Mouse
UnitRay
Type ray
Description The Ray representing the mouse pointer.
Member of Mouse
ViewSizeX
Property Integer ViewSizeX
Description Size of the viewport's X in pixels. This is the width of the game window.
Member of Mouse
ViewSizeY
Property Integer ViewSizeY
Description Size of the viewport's Y in pixels. This is the height of the game window.
Member of Mouse
X
Property Integer X
Description The X component of the position of the Mouse. This is the position of the Mouse on the screen.
Member of Mouse
Y
Property Integer Y
Description The Y component of the position of the Mouse.
Member of Mouse
Name
Type string
Description The name of the object, which is often used to identify it in the context of its parent. Note that names are not unique identifiers; multiple children of an object may share the same name. In a script where you want to access an object using a name, for example, game.Workspace["Brick"], the first object found with that name is that object. This "first object" can be found in the Explorer menu.Names are great for showing a very brief title or summary of an object.
Member of Instance
Parent
Type Instance
Description The hierarchical parent of the object. When no scripts hold references to an object, it will still be maintained as long as it's parent is set to an object which does have references to it, either by other objects or scripts. The toplevel DataModel object (the one referred to as the "game" by scripts) has no parent, but always has a reference held to it by the game engine, and exists for the duration of a session.
Member of Instance
Archivable
Type bool
Description Sets whether or not the object is saved when publishing or saving to file. Also sets whether or not the object is clonable.
Member of Instance
ClassName
Type string
Description A unique string per type of Instance. Should only be used as a unique identifier, as it does not reveal any information about nature of the type hierarchy the type is in. For this use, see IsA.
Member of Instance
RobloxLocked
Type bool
Description If true, the object and its descendants cannot be indexed or edited by a Script or LocalScript and will throw an error if it is attempted.
Member of Instance
DataCost
Type int
Description How much saving this instance with SaveInstance will add to DataComplexity
Member of Instance
Button1Down ( )
Description Fired when the mouse is in the left mouse down state.
Member of: Mouse
Button1Up ( )
Description Fired when the mouse is in the left mouse up state.
Member of: Mouse
Button2Down ( )
Description This event is supposed to fire when the mouse is in the right mouse button is pressed, but it never does because the right button is already used for camera control.
Member of: Mouse
Button2Up ( )
Description This event is supposed to fire when the right mouse button is released, but it never does because right mouse is used for camera control.
Member of: Mouse
Idle ( )
Description Fired when the mouse is left idle or not moving.
Member of: Mouse
KeyDown ( String key )
Description Fired when a Key is pressed (the key is the key).
Member of: Mouse
KeyUp ( String key )
Description Fired when a Key is released (the key is the key).
Member of: Mouse
Move ( )
Description Fired when the mouse is moved.
Member of: Mouse
WheelBackward ( )
Description This event is supposed to fire when the mouse wheel is moved backward, but it never does because the mouse wheel is used for zooming.
Member of: Mouse
WheelForward ( )
Description This event is supposed to fire when the mouse wheel is moved forward, but it never does because the mouse wheel is used for zooming.
Member of: Mouse
AncestryChanged ( Instance child, Instance parent )
Description Fired when an ancestor of the Instance the event which is a member of child has its parent changed to parent.
Member of: Instance
Changed ( Property property )
Description Fired whenever a property of the object changes.
Member of: Instance
ChildAdded ( Instance child )
Description Fired after a child is added.
Member of: Instance
ChildRemoved ( Instance child )
Description Fired when a child is removed from the object.
Member of: Instance
DescendantAdded ( Instance descendant )
Description Fired when a descendant is added to the object.
Member of: Instance
DescendantRemoving ( Instance descendant )
Description Fired when a descendant is being removed.
Member of: Instance