MouseButton1Click not firing?

Code:

				local button = v:FindFirstChildOfClass("TextButton") or v:FindFirstChildOfClass("ImageButton");
				warn(`{v.Name} setup., Button Parent: {button.Parent.Name} | Button Name: {button.Name} | Button Class Name: {button.ClassName}`)
				button.MouseButton1Click:Connect(function()
					warn(`{v.Name} clicked!`)
					self: openFrame(v);
				end)

The warning where I put all the information, warns Upgrades setup., Button Parent: Upgrades | Button Name: Button | Button Class Name: TextButton but the 2nd warn isn’t warning when I click.

1 Like

Still unsolved. No clue why it’s doing this.

Hmm… That seems odd. Try using MouseButton1Down.

This one worked for me:

if not v:IsA("TextButton") and not v:IsA("ImageButton") then continue end
local button = v 

warn(`{v.Name} setup. Button Parent: {button:GetFullName()} | Button Name: {button.Name} | Button Class Name: {button.ClassName}`)

button.MouseButton1Click:Connect(function()
	warn(`{v.Name} clicked!`)
	self:openFrame(v);
end)

break

My guess is that it had something to do with FindFirstChildOfClass. Note that I was running this in a GetDescendants loop of a ScreenGui to test it.

1 Like

This worked! You’re amazing!! I’m not sure why FindFirstchildofclass is causing a bug, considering it still found a textbutton.

1 Like

There are some methods like that which are weird like that and don’t work at all, like FindFirstDescendant

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.