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

Why does my TextButton.MouseButton1Click never fire?

I have a SurfaceGui with 3 buttons, all inside a frame. When I click them though, none of the code I have connected to the MouseButton1Click event fires. Here is the code I wrote for one of the buttons:

script.Parent.SurfaceGui.Main.btnLogout.MouseButton1Click:Connect(function()
	print("Test")
	screen.Main.Visible = false
	screen.Login.Visible = true
	screen.Login.TextLabel.Text = "Please tap your card to the reader below to begin."
	machine.Credits.Value = 0
end)

No errors appear in the output console from any script, so I have no idea why it is not firing the event and running the code. Can anyone explain? This is running on a server script, inside the screen part.

4 comments

0

To clarify, the screen part is located in a model in the workspace.

0

Doest the test print?

0

It could be that you made the main screen part not visible

0

the test does not even print. That Logout button is to take you back to the login screen

2 answers

The reason why it doesn't fire is because you're using a Server Script. It can only be fired on a LocalScript. If you really do want it to appear on everyone else's screen, then try to put the Server Script inside of the TextButton. Located in the SurfaceGUI. That will give you the permission to use script.Parent.MouseButton1Click:Connect(function(). Which would make the most sense. If it doesn't work, then don't hesitate to let me know, so I can investigate further.

Mousebutton1click needs to be used on a local script

1 comment

0

That event has worked on server scripts in the past, but this one does not.

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