Mouse1Click doesn't work

I was making a simple button, with the following script:

	print("This works")

and the following hierarchy:
Screen Shot 2021-05-31 at 6.17.17 PM
yet it doesn’t print “This Works”. Why is this?

1 Like

Replication is different between client and server. The server is probably unable to detect the input because the script is parented directly under player’s descendants, thus inactivating the script.

You should opt for a LocalScript instead.

Oh, is there any way to detect it on a server script? ('cause local scripts can be changed with exploits, I think?)

Yes, but there is no point, if exploits changes it, it will affect that player only.

Local scripts = affect the client and only that client.

Wait, but the mouse click is supposed to change something on the server, that can affect the game a lot

You can’t interact with guis that are descended from workspace, you can only interact with the guis inside of your playergui. You can see guis that are in workspace, but you can’t click them or anything. Move the billboard gui into StarterGui and set its Adornee property to the part, that will make it hover above the part.

Also, you absolutely can use a server script for this. Server scripts can detect gui input just like local scripts. However I think it’s recommended to use a local script for gui input.

Just use a local script, even if they are changeable whats stopping a exploiting form doing

About using a ServerScript to detect that seems a lot impractical than it seems to be, as you have to parent the script to somewhere with no easy access to the client’s GUI. You have to use PlayerAdded and then follow it by WaitForChild of the target GUIs and then connect the click function to them each. There’s sometimes an issue with a noticeable delay in input to server as it would be.

A LocalScript would be more effective than the server script.

1 Like

Server scripts run in your PlayerGui, although I don’t think they run in any of the player’s other folders. I guess this was to make it easier to use server scripts for your guis.

I tested it out in studio

The script prints “clicked”