MouseButton1Click Not Firing

I made a function that creates a connection with a provided button, but for some reason the clicked event isn’t working.

I tried:

  • Making a local script parented to the button (and it worked)
  • Enabling the active property (already was enabled)
  • Making sure interactable was true
  • Making sure all properties/arguments aren’t nil

Here is the function:

local function propertyConnection(button, remove, CheckBox, MixedBox, mixedValue, checkValue, propertyName)
	print("Fired")
	if remove and not button then
		for b, conn in pairs(propertyConnections) do
			conn:Disconnect()
			propertyConnections[b] = nil
		end
		return
	end
	print("past 1")

	if button and propertyConnections[button] then
		propertyConnections[button]:Disconnect()
		propertyConnections[button] = nil
	end
	
	if CheckBox == nil or MixedBox == nil or mixedValue == nil or checkValue == nil or propertyName == nil then return end
	
	print("past 2")
	
	if button and not remove then
		print("past 3")
		if button:IsA("TextButton") then
			local capturedMixed = mixedValue
			local capturedCheck = checkValue

            print("past 4")

			propertyConnections[button] = button.MouseButton1Click:Connect(function()
				print("clicked")
				if capturedMixed then
					print("true")
				elseif capturedCheck and not capturedMixed then
					print("false")
				elseif not capturedCheck and not capturedMixed then
					print("true")
				end
			end)
		end
	end
end

It prints up to past 4 but the “clicked” isnt printing.

I disconnect the functions when the module script is disabled.

Sorry if this is a simple question, I normally make my button connections like this I don’t know why it isn’t firing. Any help is appreciated! :blowfish:

If it doesn’t fire than this is a bug

Do all the parents of the button have interacteable on?

Hmm… what happens if you recursively check that the connection is still .Connected in a task.spawn()

its likely that youre just disabling the module elsewhere then, as i assume the connection not existing is the main reason this doesnt work since it prints past 4 but never clicked

I think i see whats happening. The fact that your prints reach “past 4” but never show “clicked” usually means the connection is never actually active on the GUI!! A common culprit in cases like this is where the script is running and how the button is being interacted with


Since you mentioned that a local script parented to the button works but this function dosent its almost certainly a server-side issue. TextButton.MouseButton1Click only fires in LocalScripts not in regular Scripts.

If your propertyConnection function is running in a ModuleScript on the server, the connection will never fire. That explains why “clicked” never prints!


Make sure propertyConnection is called from a LocalScript. For example;

local propertyModule = require(game.ReplicatedStorage.PropertyModule)
propertyModule.propertyConnection(myButton, false, myCheckBox, myMixedBox, mixedValue, checkValue, "MyProperty")

Ensure the button is visible, active and on a PlayerGui. MouseButton1Click will only fire if the player can interact with the button!!!

  • if you need this to run in a ModuleScript, wrap the connection in a LocalScript or pass the connection function to the LocalScript. For instance:
-- inside a LocalScript
propertyConnections[button] = button.MouseButton1Click:Connect(function()
    print("clicked")
end)


So the main issue isnt your code thingi; its the context! MouseButton1Click will never fire on the server only on the client!

Moving this connection to a LocalScript (or having the ModuleScript return the function to a LocalScript) will fix it. (i hope)

A Local Script makes things happen only on the client. The client is the players device, like their mobile or their PC is the client. What ever code runs in that local script will only be seen and happen for that player on their device.
A script runs on the Roblox server so that the code executes server side for the game.

If you run a local script and lets say you make a change for a player GUI in the local script, no one else is going to see that change. Unless you run a Remote Event. You can fire and event to the server from the local script.

Like So:
event:FireServer(parameter goes here)

Then you can have a script in Server Script Service, make the connection or receive that event that is fired, and fire another event to send the update to all Clients, using a connection event function.
Like so:
event.OnServerEvent:Connect(function)
anotherEvent:FireAllClients(parameter being passed goes here)
end)

Then in another local script perhaps inside of the GUI or inside of Starter Player Scripts you can again receive the event.

Like so:
anotherEvent.OnClientEvent:Connect(function(parameter that was passed goes here)
– code that updates whatever your trying to achieve
end)

The function is in a module script on the client.
I also made sure the connection exists and isn’t nil after creation and it does exist
img-2025-09-04-19-17-56

Is connection itself still has .Connected equal to true?

https://create.roblox.com/docs/reference/engine/datatypes/RBXScriptConnection#Connected