Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why does MouseButton1Click doesn't work? Pls Help The MouseButton1Click wont work :(

local DonateButton = script.Parent local DonateFrame = script.Parent.Parent.DonateFrame

DonateFrame.Visible = false DonateButton.MouseButton1Click:Connect(function() if DonateFrame.Visible == false then DonateFrame.Visible = true DonateButton.Text = "Close" else DonateFrame.Visible = false DonateButton.Text = "Donate" end end)

It says that the MouseButton1Click not recognize? What do I do?

3 answers

mousebutton1click will only work on pc, use MouseButton1Down for automatic mobile support

local DonateButton = script.Parent 
local DonateFrame = script.Parent.Parent.DonateFrame

DonateFrame.Visible = false

DonateButton.MouseButton1Down:Connect(function() 
	if DonateFrame.Visible == false then
		 DonateFrame.Visible = true 
		DonateButton.Text = "Close" 
	else 
		DonateFrame.Visible = false 
		DonateButton.Text = "Donate" 
	end 
end)

Hello, can you please put this in a code block (Please make sure that the script is a local script, if not the script will fail.)

local DonateButton = script.Parent 
local DonateFrame = script.Parent.Parent.DonateFrame

DonateFrame.Visible = false 
DonateButton.Activated:Connect(function()  -- Activated works both on pc and mobile and serves the same purpose as MouseButton1Click
if DonateFrame.Visible == false then 
DonateFrame.Visible = true DonateButton.Text = "Close" 
	else 
DonateFrame.Visible = false
DonateButton.Text = "Donate" 
	end 
end)

Pretty sure MouseButton1Click works with pc and mobile. Make sure DonateButton is a textbutton/imagebutton or something that you can actually click. Frames/TextLabels/ImageLabels wont work.

This discussion is preserved as it was. New answers, comments, and votes are closed.