MouseButton1Click only fires when the mouse button is released

  1. Run this test project: Mouseclick.rbxl (32.2 KB)
  2. Click on the central button:
    image
  3. Release the mouse and only then MouseButton1Click will be fired…
local Player 	= game.Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")
local Gui 		= PlayerGui:WaitForChild("ScreenGui")
local Frame 	= Gui.Frame
local Button	= Frame:WaitForChild("ImageButton")

Button.MouseButton1Click:Connect(function()
	print("Button: ", Button)
end)

What’s wrong?

Well, it is called “Click” for a reason, you need to finish the click for it to run. if you want it to run while they are holding, you would use Button.MouseButton1Down

2 Likes
local Player 	= game.Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")
local Gui 		= PlayerGui:WaitForChild("ScreenGui")
local Frame 	= Gui.Frame
local Button	= Frame:WaitForChild("ImageButton")


Button.InputBegan:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		print("Right input")
	else
		print("Wrong input")
	end
end)

This should fire at the moment a mouse button is pressed.

3 Likes