Source: Roblox Creator Hub · CC BY 4.0 · View source · Code samples: MIT Imported 2026-10-03. Formatting adapted for this site.
Mouse
Inherits from: Instance → Object
Mouse has been superseded by UserInputService and ContextActionService, which cover a broader scope, are more feature rich, and support cross-platform patterns better. It remains supported because of its widespread use, but you should strongly consider using these alternatives.
The Mouse object houses various API for pointers, primarily for buttons and raycasting. It can be accessed through Player:GetMouse() called on the Players.LocalPlayer in a LocalScript. It is also passed by the Tool.Equipped event.
- It is most notable for the
Iconproperty, which changes the cursor's appearance. - It continually raycasts the screen mouse position into the 3D world using the
TargetFilterproperty, storing the results of the raycast in theHit,Target, andTargetSurfaceproperties. These can be useful for simple cases, butWorldRoot:Raycast()should be used in more complicated raycasting scenarios. Pluginscan usePlugin:GetMouse()to get aPluginMouse, which behaves similarly.
-- From a LocalScript:
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local mouse = player:GetMouse()
-- Setting the mouse icon
mouse.Icon = "rbxasset://SystemCursors/Wait" Note:
This object does not control/restrict pointer movement. For this, see
UserInputService.MouseBehaviorandUserInputService.MouseDeltaSensitivity.If two functions are connected to same input event, such as
Button1Down, both functions will run when the event fires. There is no concept of sinking/passing input, as events don't support this behavior. However,ContextActionServicedoes have this behavior throughBindAction.While a mouse may not be available on all platforms, Mouse will still function on mobile (touch) and console (gamepad), which don't typically have mice or pointer hardware. For explicit cross-platform behaviors, use
UserInputServiceandContextActionService.See Input and Camera for more information on customizing inputs in your experience.
Inherits from: Instance
Descendants: PlayerMouse, PluginMouse
Memory category: Instances
Tags: NotCreatable
Properties
| Name | Type / Returns | Description |
|---|---|---|
| Mouse.Hit | CFrame | The CFrame of the mouse's position in 3D space. |
| Mouse.hit | CFrame | |
| Mouse.Icon | ContentId | The content ID of the image used as the Mouse icon. |
| Mouse.IconContent | Content | The content of the image used as the Mouse icon. Only supports asset URIs. |
| Mouse.Origin | CFrame | A CFrame positioned at the Workspace.CurrentCamera and oriented toward the mouse's 3D position. |
| Mouse.Target | BasePart | The object in 3D space the mouse is pointing to. |
| Mouse.target | BasePart | |
| Mouse.TargetFilter | Instance | Determines an object (and its descendants) to be ignored when determining Mouse.Hit and Mouse.Target. |
| Mouse.TargetSurface | NormalId | Indicates the NormalId of the BasePart surface at which the mouse is pointing. |
| Mouse.UnitRay | Ray | A Ray directed towards the mouse's world position, originating from the Workspace.CurrentCamera world position. |
| Mouse.ViewSizeX | int | Describes the width of the game window in pixels. |
| Mouse.ViewSizeY | int | Describes the height of the game window in pixels. |
| Mouse.X | int | Describes the X (horizontal) component of the mouse's position on the screen. |
| Mouse.Y | int | Describes the Y (vertical) component of the mouse's screen position. |
Inherited from Instance
| Name | Type / Returns | Description |
|---|---|---|
| Instance.Archivable | boolean | Determines if an Instance and its descendants can be cloned using Instance:Clone(), and can be saved/published. |
| Instance.archivable | boolean | |
| Instance.Capabilities | SecurityCapabilities | The set of capabilities allowed to be used for scripts inside this container. |
| Instance.IsInSandbox | boolean | Indicates whether the instance is inside a sandboxed container. |
| Instance.Name | string | A non-unique identifier of the Instance. |
| Instance.Parent | Instance | Determines the hierarchical parent of the Instance. |
| Instance.PredictionMode | PredictionMode | Reflects the client-side prediction mode applied to the instance under server-authoritative physics. |
| Instance.RobloxLocked | boolean | A deprecated property that used to protect CoreGui objects. |
| Instance.Sandboxed | boolean | When enabled, the instance can only access abilities in its Capabilities list. |
| Instance.UniqueId | UniqueId | A unique identifier for the instance. |
Inherited from Object
| Name | Type / Returns | Description |
|---|---|---|
| Object.ClassName | string | A read-only string representing the class this Object belongs to. |
| Object.className | string |
Mouse.Hit
This property indicates CFrame of the mouse's position in 3D space. Note that Mouse.TargetFilter and its descendants will be ignored.
Developers can get obtain the position of Hit like so:
local position = mouse.Hit.Position Hit is often used by Tools to fire a weapon towards the mouse in third person.
Developers looking for the BasePart the mouse is pointing at should use Mouse.Target.
How is Mouse.Hit calculated?
The position of the Hit CFrame is calculated as the point of intersection between the mouse's internal Ray (an extended version of Mouse.UnitRay) and an object in 3D space (such as a part).
The orientation of the Hit CFrame corresponds with the direction of the Mouse.UnitRay.
local unitRayDirection = mouse.UnitRay.Direction
local mouseHitDirection = mouse.Hit.lookVector
-- unitRayDirection ≈ mouseHitDirection
-- the vectors are approximately equal Note, the roll of the Workspace.CurrentCamera is not used when calculating the orientation of the Hit CFrame.
The mouse's internal ray extends for 1,000 studs. If the mouse is not pointing at an object in 3D space (for example when pointing at the sky), this property will be 1,000 studs away from the Workspace.CurrentCamera.
| Field | Value |
|---|---|
| type | CFrame |
| tags | ["ReadOnly","NotReplicated"] |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Data |
| serialization | {"can_load":false,"can_save":true} |
| capabilities | ["Input"] |
Code samples: View on Creator Hub (Mouse-Hit-Laser-Beam, mouse-origin-v-mouse-hit).
Mouse.hit
Deprecated. This property is a deprecated variant of Mouse.Hit which should be used instead.
| Field | Value |
|---|---|
| type | CFrame |
| tags | ["Hidden","ReadOnly","NotReplicated","Deprecated"] |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Data |
| serialization | {"can_load":false,"can_save":false} |
| capabilities | ["Input"] |
Mouse.Icon
Icon is a property that determines the image used as the pointer. If blank, a default arrow is used. While the cursor hovers over a GuiButton, this property is temporarily ignored.
To hide the cursor entirely, do not use a transparent image – instead, set UserInputService.MouseIconEnabled to false.
For getting/setting the user mouse icon in experiences, you should use UserInputService.MouseIcon. Mouse.Icon will be deprecated after the new API for plugins to set the mouse cursor is released.
Designing a Cursor
The following guidelines may prove useful when creating your own mouse cursors:
- The dimensions of the image used determines the size of the cursor.
- The dimensions of the image should not exceed 256 pixels on any axis.
- The center of the image is where mouse inputs are issued.
- The default mouse image is 64x64 pixels, with the mouse taking up 17x24 pixels of space.
System Cursors
When using a PluginMouse retrieved from Plugin:GetMouse(), you can use the following icons similar to your system's default cursors, such as hands, arrows, I-beams, etc. You can use these with GUI events like MouseEnter, MouseLeave, and MouseButton1Down to provide a consistent Studio experience when interacting with certain kinds of GUI components. Note that these only work for Studio plugins; they will not work for other Mouse objects.
| Look* | Asset | Suggested Use |
|---|---|---|
rbxasset://SystemCursors/Arrow | Default clicking and selection. | |
rbxasset://SystemCursors/PointingHand | Hovering over an active link/button. | |
rbxasset://SystemCursors/OpenHand | Hovering over a draggable item. | |
rbxasset://SystemCursors/ClosedHand | Dragging an item. | |
rbxasset://SystemCursors/IBeam | Hovering in a text field. | |
rbxasset://SystemCursors/SizeNS | Hovering over a vertical resize handle. | |
rbxasset://SystemCursors/SizeEW | Hovering over a horizontal resize handle. | |
rbxasset://SystemCursors/SizeNESW | Hovering over a corner resize handle. | |
rbxasset://SystemCursors/SizeNWSE | Hovering over a corner resize handle. | |
rbxasset://SystemCursors/SizeAll | Hovering over a multi-direction resize handle. | |
rbxasset://SystemCursors/SplitNS | Hovering over a vertical "split" handle. | |
rbxasset://SystemCursors/SplitEW | Hovering over a horizontal "split" handle. | |
rbxasset://SystemCursors/Forbidden | Hovering over a locked/forbidden item. | |
rbxasset://SystemCursors/Wait | Indicating an action is in progress. | |
rbxasset://SystemCursors/Busy | Indicating the system is busy. | |
rbxasset://SystemCursors/Cross | Hovering over a pinpoint selection area. |
- These appearances are approximations — the actual look is dependent on your operating system.
| Field | Value |
|---|---|
| type | ContentId |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Data |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["Input"] |
Code samples: View on Creator Hub (dragon-mouse-icon).
Mouse.IconContent
Icon is a property that determines the image used as the pointer. If blank, a default arrow is used. While the cursor hovers over a GuiButton, this property is temporarily ignored. This property only supports asset URIs.
To hide the cursor entirely, do not use a transparent image – instead, set UserInputService.MouseIconEnabled to false.
For getting/setting the user mouse icon in experiences, you should use UserInputService.MouseIcon. Mouse.Icon will be deprecated after the new API for plugins to set the mouse cursor is released.
Designing a Cursor
The following guidelines may prove useful when creating your own mouse cursors:
- The dimensions of the image used determines the size of the cursor.
- The dimensions of the image should not exceed 256 pixels on any axis.
- The center of the image is where mouse inputs are issued.
- The default mouse image is 64x64 pixels, with the mouse taking up 17x24 pixels of space.
System Cursors
When using a PluginMouse retrieved from Plugin:GetMouse(), you can use the following icons similar to your system's default cursors, such as hands, arrows, I-beams, etc. You can use these with GUI events like MouseEnter, MouseLeave, and MouseButton1Down to provide a consistent Studio experience when interacting with certain kinds of GUI components. Note that these only work for Studio plugins; they will not work for other Mouse objects.
| Look* | Asset | Suggested Use |
|---|---|---|
rbxasset://SystemCursors/Arrow | Default clicking and selection. | |
rbxasset://SystemCursors/PointingHand | Hovering over an active link/button. | |
rbxasset://SystemCursors/OpenHand | Hovering over a draggable item. | |
rbxasset://SystemCursors/ClosedHand | Dragging an item. | |
rbxasset://SystemCursors/IBeam | Hovering in a text field. | |
rbxasset://SystemCursors/SizeNS | Hovering over a vertical resize handle. | |
rbxasset://SystemCursors/SizeEW | Hovering over a horizontal resize handle. | |
rbxasset://SystemCursors/SizeNESW | Hovering over a corner resize handle. | |
rbxasset://SystemCursors/SizeNWSE | Hovering over a corner resize handle. | |
rbxasset://SystemCursors/SizeAll | Hovering over a multi-direction resize handle. | |
rbxasset://SystemCursors/SplitNS | Hovering over a vertical "split" handle. | |
rbxasset://SystemCursors/SplitEW | Hovering over a horizontal "split" handle. | |
rbxasset://SystemCursors/Forbidden | Hovering over a locked/forbidden item. | |
rbxasset://SystemCursors/Wait | Indicating an action is in progress. | |
rbxasset://SystemCursors/Busy | Indicating the system is busy. | |
rbxasset://SystemCursors/Cross | Hovering over a pinpoint selection area. |
- These appearances are approximations — the actual look is dependent on your operating system.
| Field | Value |
|---|---|
| type | Content |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Data |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["Input"] |
Code samples: View on Creator Hub (dragon-mouse-icon).
Mouse.Origin
The origin Mouse property is a CFrame indicating where the mouse originated from. It is positioned at the Workspace.CurrentCamera and oriented toward the mouse's 3D position.
Mouse.UnitRay starts at the same position as Origin, and extends for a stud in the same direction.
local unitRay = mouse.UnitRay
local origin = mouse.Origin
-- unitRay.Direction = origin.p
-- unitRay.Direction ≈ origin.lookVector For the position of the Mouse in 3D space, see Mouse.Hit.
| Field | Value |
|---|---|
| type | CFrame |
| tags | ["ReadOnly","NotReplicated"] |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Data |
| serialization | {"can_load":false,"can_save":true} |
| capabilities | ["Input"] |
Code samples: View on Creator Hub (mouse-origin-v-mouse-hit).
Mouse.Target
The object in 3D space the mouse is pointing to.
Note:
- If
Mouse.TargetFilterhas been set, the target filter and its descendants will be ignored. - When the mouse is not pointing at a
BasePart, for example when it is pointing at the sky, Target will benil. - Developers looking for the position of the mouse in 3D space should use
Mouse.Hit.
| Field | Value |
|---|---|
| type | BasePart |
| tags | ["ReadOnly","NotReplicated"] |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Data |
| serialization | {"can_load":false,"can_save":true} |
| capabilities | ["Input"] |
Code samples: View on Creator Hub (Mouse-Button1Down).
Mouse.target
Deprecated. This property is a deprecated variant of Mouse.Target which should be used instead.
| Field | Value |
|---|---|
| type | BasePart |
| tags | ["ReadOnly","NotReplicated","Deprecated"] |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Data |
| serialization | {"can_load":false,"can_save":false} |
| capabilities | ["Input"] |
Mouse.TargetFilter
This property determines an object to be ignored by the mouse when calculating Mouse.Hit and Mouse.Target. The descendants of the object are also ignored, so it is possible to ignore multiple objects so long as they are a descendant of the object to which this property is set. This property is useful when filtering models containing special effects or decorations that should not affect Mouse.Hit or Mouse.Target.
This property can be set to any Instance or nil, for example:
local Players = game:GetService("Players")
local Workspace = game:GetService("Workspace")
local player = Players.LocalPlayer
local mouse = player:GetMouse()
mouse.TargetFilter = Workspace.Model Note that the Character of the Players.LocalPlayer is ignored by the mouse automatically.
| Field | Value |
|---|---|
| type | Instance |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Data |
| serialization | {"can_load":true,"can_save":true} |
| capabilities | ["Input"] |
Mouse.TargetSurface
This property indicates the NormalId of the BasePart surface at which the mouse is pointing. This property is derived from the world position of mouse (Mouse.Hit) and the part toward which the mouse is pointing (Mouse.Target).
This property isn't meaningful when the mouse is not pointing at a part, for example when the mouse is pointing at the sky. At the moment, this property is set to 'Right' under these circumstances. Before using this property, check that the mouse's target is not nil.
| Field | Value |
|---|---|
| type | NormalId |
| tags | ["ReadOnly","NotReplicated"] |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Data |
| serialization | {"can_load":false,"can_save":true} |
| capabilities | ["Input"] |
Code samples: View on Creator Hub (Mouse-TargetSurface, Mouse-TargetSurface-2).
Mouse.UnitRay
The UnitRay property is a Ray directed toward the mouse's position in 3D space (described by Mouse.Hit). It originates from the CFrame of the Workspace.CurrentCamera. Like all unit rays, it has a distance of 1.
| Field | Value |
|---|---|
| type | Ray |
| tags | ["ReadOnly","NotReplicated"] |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Data |
| serialization | {"can_load":false,"can_save":true} |
| capabilities | ["Input"] |
Code samples: View on Creator Hub (Mouse-UnitRay).
Mouse.ViewSizeX
The ViewSizeX property describes the horizontal component of the game window's size in pixels.
| Field | Value |
|---|---|
| type | int |
| tags | ["ReadOnly","NotReplicated"] |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Data |
| serialization | {"can_load":false,"can_save":true} |
| capabilities | ["Input"] |
Code samples: View on Creator Hub (normalized-mouse-position).
Mouse.ViewSizeY
The ViewSizeY property describes the vertical component of the game window's size in pixels. This length includes the space used by the topbar.
| Field | Value |
|---|---|
| type | int |
| tags | ["ReadOnly","NotReplicated"] |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Data |
| serialization | {"can_load":false,"can_save":true} |
| capabilities | ["Input"] |
Code samples: View on Creator Hub (normalized-mouse-position).
Mouse.X
When detecting changes in the mouse's position on-screen, it is recommended that you use ContextActionService:BindAction() with UserInputType.MouseMovement or UserInputService.InputChanged, which both describe the position of the mouse using the Position (a Vector3) of an InputObject, instead of using this and related properties.
The X property describes the horizontal component of the mouse's position on the screen. The position is measured in pixels relative to the top left corner, under the topbar. This property can be used in conjunction with Mouse.Y to produce a Vector2 representing the mouse's position:
local position = Vector2.new(mouse.X, mouse.Y) This property does not fire Changed or the signal returned from GetPropertyChangedSignal. Use the Mouse.Move event instead.
| Field | Value |
|---|---|
| type | int |
| tags | ["ReadOnly","NotReplicated"] |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Data |
| serialization | {"can_load":false,"can_save":true} |
| capabilities | ["Input"] |
Code samples: View on Creator Hub (normalized-mouse-position).
Mouse.Y
When detecting changes in the mouse's position on-screen, it is recommended that you use ContextActionService:BindAction() with UserInputType.MouseMovement or UserInputService.InputChanged, which both describe the position of the mouse using the Position (a Vector3) of an InputObject, instead of using this and related properties.
The Y property describes the vertical component of the mouse's position on the screen. The position is measured in pixels relative to the top left corner, under the topbar. This property can be used in conjunction with Mouse.X to produce a Vector2 representing the mouse's position:
local position = Vector2.new(mouse.X, mouse.Y) This property does not fire Changed or the signal returned from GetPropertyChangedSignal. Use the Mouse.Move event instead.
| Field | Value |
|---|---|
| type | int |
| tags | ["ReadOnly","NotReplicated"] |
| security | {"read":"None","write":"None"} |
| thread safety | ReadSafe |
| category | Data |
| serialization | {"can_load":false,"can_save":true} |
| capabilities | ["Input"] |
Code samples: View on Creator Hub (normalized-mouse-position).
Events
| Name | Type / Returns | Description |
|---|---|---|
| Mouse.Button1Down | Fires when the left mouse button is pressed. | |
| Mouse.Button1Up | Fires when the left mouse button is released. | |
| Mouse.Button2Down | Fires when the right mouse button is pressed. | |
| Mouse.Button2Up | Fired when the right mouse button is released. | |
| Mouse.Idle | Fired during every heartbeat that the mouse isn't being passed to another mouse event. | |
| Mouse.KeyDown | Fires when a Key is pressed. | |
| Mouse.keyDown | ||
| Mouse.KeyUp | Fires when a Key is released. | |
| Mouse.Move | Fired when the mouse is moved. | |
| Mouse.WheelBackward | Fires when the mouse wheel is scrolled backwards. | |
| Mouse.WheelForward | Fires when the mouse wheel is scrolled forwards. |
Inherited from Instance
| Name | Type / Returns | Description |
|---|---|---|
| Instance.AncestryChanged | Fires when the Instance.Parent property of this object or one of its ancestors is changed. | |
| Instance.AttributeChanged | Fires whenever an attribute is changed on the Instance. | |
| Instance.ChildAdded | Fires after an object is parented to this Instance. | |
| Instance.childAdded | ||
| Instance.ChildRemoved | Fires after a child is removed from this Instance. | |
| Instance.DescendantAdded | Fires after a descendant is added to the Instance. | |
| Instance.DescendantRemoving | Fires immediately before a descendant of the Instance is removed. | |
| Instance.Destroying | Fires immediately before (or is deferred until after) the instance is destroyed via Instance:Destroy(). | |
| Instance.StyledPropertiesChanged | Fires whenever any style property is changed on the instance, including when a property is set to nil. |
Inherited from Object
| Name | Type / Returns | Description |
|---|---|---|
| Object.Changed | Fires immediately after a property of the object changes, with some limitations. |
Mouse.Button1Down
This event fires when the player presses their left mouse button. Note that this can be accessed from a Tool; for example, when placed in a LocalScript, the code below prints Button1Down whenever the left mouse button is pressed.
local tool = script.Parent -- Make sure this is a Tool object
tool.Equipped:Connect(function(mouse)
mouse.Button1Down:Connect(function()
print("Button1Down")
end)
end) You can find out the position of the mouse in world space and if it's pointing at any BasePart using the Hit and Target properties.
| Field | Value |
|---|---|
| security | None |
| capabilities | ["Input"] |
Mouse.Button1Up
This event fires when the player releases their left mouse button. Note that this can be accessed from a Tool; for example, when placed in a LocalScript, the code below prints Button1Up whenever the left mouse button is released.
local tool = script.Parent -- Make sure this is a Tool object
tool.Equipped:Connect(function(mouse)
mouse.Button1Up:Connect(function()
print("Button1Up")
end)
end) You can find out the position of the mouse in world space and if it's pointing at any BasePart using the Hit and Target properties.
| Field | Value |
|---|---|
| security | None |
| capabilities | ["Input"] |
Mouse.Button2Down
This event fires when the player presses their right mouse button. Note that this can be accessed from a Tool; for example, when placed in a LocalScript, the code below prints Button2Down whenever the right mouse button is pressed.
local tool = script.Parent -- Make sure this is a Tool object
tool.Equipped:Connect(function(mouse)
mouse.Button2Down:Connect(function()
print("Button2Down")
end)
end) You can find out the position of the mouse in world space and if it's pointing at any BasePart using the Hit and Target properties.
| Field | Value |
|---|---|
| security | None |
| capabilities | ["Input"] |
Mouse.Button2Up
This event fires when the player releases their right mouse button. Note that this can be accessed from a Tool; for example, when placed in a LocalScript, the code below prints Button2Up whenever the right mouse button is released.
local tool = script.Parent -- Make sure this is a Tool object
tool.Equipped:Connect(function(mouse)
mouse.Button2Up:Connect(function()
print("Button2Up")
end)
end) You can find out the position of the mouse in world space and if it's pointing at any BasePart using the Hit and Target properties.
| Field | Value |
|---|---|
| security | None |
| capabilities | ["Input"] |
Mouse.Idle
Fired during every heartbeat that the mouse isn't being passed to another mouse event.
Note, this event should not be used to determine when the mouse is still. As it fires every heartbeat it will fire between Mouse.Move events.
For information on how to obtain the Mouse object, please see the Mouse page.
Developers can find out the position of the mouse in world-space, and if it is pointing at any BasePart using the Mouse.Hit and Mouse.Target properties.
Note, developers are recommended to use UserInputService instead of the Mouse object in new work.
| Field | Value |
|---|---|
| security | None |
| capabilities | ["Input"] |
Code samples: View on Creator Hub (Mouse-Idle1).
Mouse.KeyDown
Deprecated. Mouse events have been superseded by UserInputService which should be used in all new work.
This event fires when a Key is pressed, with the passed argument being the key that was pressed.
Note:
- Not all keys generate this event. However, you can get around this with a few of the keys, "/" for example, by using the
Mouse.KeyUpevent. - Some keys generate the same string as other keys.
- It's possible for the string to be empty (possibly due to "\0" key code).
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| key | string |
| Field | Value |
|---|---|
| tags | ["Deprecated"] |
| security | None |
| capabilities | ["Input"] |
Code samples: View on Creator Hub (Mouse-KeyDown1).
Mouse.keyDown
Deprecated. This event is a deprecated variant of Mouse.KeyDown which has also been deprecated. Neither event should be used in new work.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| key | string |
| Field | Value |
|---|---|
| tags | ["Deprecated"] |
| security | None |
| capabilities | ["Input"] |
Mouse.KeyUp
Deprecated. Mouse events have been superseded by UserInputService which should be used in all new work.
This event is fired when a Key is released, with the passed argument being the key that was released.
Note:
- Not all keys generate this event. However, you can get around this with a few of the keys, "/" for example, by using the [[API:Class/Mouse/KeyUp|KeyUp]] event.
- Some keys generate the same string as other keys.
- It's possible for the string to be empty (possibly due to "\0" key code).
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| key | string |
| Field | Value |
|---|---|
| tags | ["Deprecated"] |
| security | None |
| capabilities | ["Input"] |
Code samples: View on Creator Hub (Mouse-KeyUp1).
Mouse.Move
Fired when the mouse is moved.
Note, this event is fired when the mouse's position is updated, therefore it will fire repeatedly while being moved.
For information on how to obtain the Mouse object, please see the Mouse page.
Developers can find out the position of the mouse in world-space, and if it is pointing at any BasePart using the Mouse.Hit and Mouse.Target properties.
mouse.Move:Connect(function()
local position = mouse.Hit.p
local target = mouse.Target
print(target, position)
end) Note, developers are recommended to use UserInputService instead of the Mouse object in new work.
| Field | Value |
|---|---|
| security | None |
| capabilities | ["Input"] |
Code samples: View on Creator Hub (move-parts-with-the-mouse).
Mouse.WheelBackward
The WheelBackward event fires when the mouse wheel is scrolled backwards. Possible uses for this event include toggling a gun's scope in a first person shooter (FPS) or zooming the player's camera.
This can be used alongside the scrolling forward event, Mouse.WheelForward.
For information on how to obtain the Mouse object, please see the Mouse page.
Note, developers are recommended to use UserInputService instead of the Mouse object in new work.
| Field | Value |
|---|---|
| security | None |
| capabilities | ["Input"] |
Code samples: View on Creator Hub (Mouse-WheelBackward1).
Mouse.WheelForward
The WheelForward event fires when the mouse wheel is scrolled forwards. Possible uses for this event include toggling a gun's scope in a first person shooter (FPS) or zooming the player's camera.
This can be used alongside the scrolling backward event, Mouse.WheelBackward.
For information on how to obtain the Mouse object, please see the Mouse page.
Note, developers are recommended to use UserInputService instead of the Mouse object in new work.
| Field | Value |
|---|---|
| security | None |
| capabilities | ["Input"] |
Code samples: View on Creator Hub (Mouse-WheelForward1).
Methods
Inherited from Instance
| Name | Type / Returns | Description |
|---|---|---|
| Instance:AddTag | () | Applies a tag to the instance. |
| Instance:children | Instances | Returns an array of the object's children. |
| Instance:ClearAllChildren | () | This method destroys all of an instance's children. |
| Instance:Clone | Instance | Create a copy of an instance and all its descendants, ignoring instances that are not Archivable. |
| Instance:clone | Instance | |
| Instance:Destroy | () | Sets the Instance.Parent property to nil, locks the Instance.Parent property, disconnects all connections, and calls Destroy() on all children. |
| Instance:destroy | () | |
| Instance:FindFirstAncestor | Instance? | Returns the first ancestor of the Instance whose Instance.Name is equal to the given name. |
| Instance:FindFirstAncestorOfClass | Instance? | Returns the first ancestor of the Instance whose Object.ClassName is equal to the given className. |
| Instance:FindFirstAncestorWhichIsA | Instance? | Returns the first ancestor of the Instance for whom Object:IsA() returns true for the given className. |
| Instance:FindFirstChild | Instance? | Returns the first child of the Instance found with the given name. |
| Instance:findFirstChild | Instance | |
| Instance:FindFirstChildOfClass | Instance? | Returns the first child of the Instance whose ClassName is equal to the given class name. |
| Instance:FindFirstChildWhichIsA | Instance? | Returns the first child of the Instance for whom Object:IsA() returns true for the given className. |
| Instance:FindFirstDescendant | Instance? | Returns the first descendant found with the given Instance.Name. |
| Instance:GetActor | Actor? | Returns the Actor associated with the Instance, if any. |
| Instance:GetAttribute | Variant | Returns the value which has been assigned to the given attribute name. |
| Instance:GetAttributeChangedSignal | RBXScriptSignal | Returns an event that fires when the given attribute changes. |
| Instance:GetAttributes | Dictionary | Returns a dictionary of the instance's attributes. |
| Instance:GetChildren | Instances | Returns an array containing all of the instance's children. |
| Instance:getChildren | Instances | |
| Instance:GetDebugId | string | Returns a coded string of the debug ID used internally by Roblox. |
| Instance:GetDescendants | Instances | Returns an array containing all of the descendants of the instance. |
| Instance:GetFullName | string | Returns a string describing the instance's ancestry. |
| Instance:GetStyled | Variant | Returns the styled or explicitly modified value of the specified property, or else the default property value if it hasn't been styled/modified. |
| Instance:GetStyledPropertyChangedSignal | RBXScriptSignal | Returns an event that fires when the given style property changes on the instance. |
| Instance:GetTags | Array | Gets an array of all tags applied to the instance. |
| Instance:HasTag | boolean | Check whether the instance has a given tag. |
| Instance:IsAncestorOf | boolean | Returns true if an Instance is an ancestor of the given descendant. |
| Instance:IsDescendantOf | boolean | Returns true if an Instance is a descendant of the given ancestor. |
| Instance:isDescendantOf | boolean | |
| Instance:IsPropertyModified | boolean | Returns true if the value stored in the specified property is not equal to the code-instantiated default. |
| Instance:QueryDescendants | Instances | Returns an array containing all descendants of the instance that match the selector string. |
| Instance:Remove | () | Sets the object's Parent to nil, and does the same for all its descendants. |
| Instance:remove | () | |
| Instance:RemoveTag | () | Removes a tag from the instance. |
| Instance:ResetPropertyToDefault | () | Resets a property to its default value. |
| Instance:SetAttribute | () | Sets the attribute with the given name to the given value. |
| Instance:WaitForChild | Instance | Returns the child of the Instance with the given name. If the child does not exist, it will yield the current thread until it does. |
Inherited from Object
| Name | Type / Returns | Description |
|---|---|---|
| Object:GetPropertyChangedSignal | RBXScriptSignal | Get an event that fires when a given property of the object changes. |
| Object:IsA | boolean | Returns true if an object's class matches or inherits from a given class. |
| Object:isA | boolean |