PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

Button1Up

Fires when the left mouse button is released.

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.


Code Samples


Color Randomizer Tool (Button1Up)

The follow example changes the BasePart/BrickColor of every BasePart the player clicks and releases their mouse on.

In order for a part to change color, the player’s mouse must be over the part both when the player presses their left mouse button down and when the player releases their left mouse button.

local mouse = game.Players.LocalPlayer:GetMouse()
local target = nil

mouse.Button1Down:Connect(function()
	target = mouse.Target
end)

mouse.Button1Up:Connect(function()
	if target == mouse.Target then
		target.BrickColor = BrickColor.Random()
	end
end)