GUI Buttons Support

Hello, stupid question but needed.

So you guys know that we have a ClickDetector, and that we can detect the click parent.
Is it possible to use a TextButton/ImageButton to have a variable called “Click” and a way to determine the “Click” parent (player who activated it)?

Or this is just restricted to clickdetector?

If the TextButton/ImageButton is in a ScreenGui/BillboardGui in workspace, you can’t find the clicker of the button. You’ll need to put the TextButton/ImageButton in each player’s gui to find out who pressed it.

My GUI is on a SurfaceGUI, I tried to do like a screen and once it was clicked it checked someones rank to either display or not the GUI. So I dont think I can work that one out…

I guess using clickdetectors would be the best and instead jsut let a surfaceGUi without code?

SurfaceGUIs have an Adornee property which allows you to adorn the GUI onto a part. It is possible.

I however have 10 parts that are using the same GUI, it would be unuseful and messy doing so

ImageButtons and TextButtons have no returned values so it is impossible to check what player clicked them. Usually TextButtons and ImageButtons are used on the clients screen so there would be no need for a return value of the player because they are being ran on the client.

A seemingly more hacky approach to your problem could be to handle all the clicking of the TextButton/ImageButton on the client. Then when the button is clicked you could send a RemoteEvent to the server to update all the other players SurfaceGui’s. When a RemoteEvent is fired from the client > server the returned value is the player who sent the Remote.

I tried that but local scripts would not run so I decided to use click detectors.

Are you trying to run the LocalScript on the server? If so then the LocalScript wont run because it needs to be on the client. A good place to place the LocalScript could be in StarterPlayerScripts or StarterGui.

The proper way to make an interactive world space Gui object (BillboardGui or SurfaceGui) is to put it in the player’s PlayerGui and set the adornee to a part in the Workspace. From there, you will need your LocalScript in the Gui and for any interactions, you can use LocalPlayer and fire off remotes.

LocalScripts do not function in the workspace which is the cause for a script not running for a SurfaceGui or BillboardGui. Don’t try to use a server script either, you should never have them in Guis. LocalScript always to control Gui interaction.

1 Like