MouseButton1Click problem

Hello developer, Can someone help me with my script?

script.Parent.Parent.RoomFrame.LeaveButton.MouseButton1Click:Connect(function()
	SelectChapter = "N/A"
	PAmount = 1
	PlayersAmountStats = 1
	PlayersAmount.Amount.Text = "1/4"
	Check = false
	PrivacyCheck = "Public"
	PasswordBox.Text = "N/A"
end)

So this script above is not getting active even though the button is located correctly.
What is the problem?

You can add a print statement to see if the function is being called by the mouse click.

script.Parent.Parent.RoomFrame.LeaveButton.MouseButton1Click:Connect(function()
	print("Button Was Clicked")
	SelectChapter = "N/A"
	PAmount = 1
	PlayersAmountStats = 1
	PlayersAmount.Amount.Text = "1/4"
	Check = false
	PrivacyCheck = "Public"
	PasswordBox.Text = "N/A"
end)

The other thing is to make sure this is a Local Script and not a Server script.

Is the ‘script.Parent.Parent.RoomFrame.LeaveButton’ a button? Make sure you didn’t accidently create a Textlabel. Also, is the ‘script.Parent.Parent.RoomFrame.LeaveButton’ correct? Maybe you added the function to another button?

Bro, the leave button is inside a frame, and when I add a script inside that frame with the button, it works, but when I try to get the button from a local script that is not inside the same frame, it does not work. There are no errors, but idk.

The button is in PlayerGui or is it a “physical button” (3d object) and it is in workspace?

The button in the player gui
Do I use a remote function or something, or is there a solution?

maybe you have an invisible gui in front of your button?

It does not show the print statement I tried it

Bro, did you read what I typed? I said that when I get the button from a script that is inside the same frame as the button, it works, but when I move the button to another frame that is not the same as the button, it does not work.

You didn’t change the buttons path to the place you moved to, replace the location of the button in the local script to the correct location of the button after you moved it

Bro, the path is correct. If it’s wrong, I’d get an output error. Nothing is wrong; everything is fine, but the problem is that the mousebutton function is not getting called.

It can help to keep scripts in one folder so you don’t get lost in the pathways.

You also don’t have to hunt for the scripts if you’ve forgotten where they are.

Here is a file that might help:

button.rbxl (61.5 KB)

Hello @here, I just fixed the problem. To fix it, I just changed MouseButton1Click to MouseButton1Down.

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