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

How could I find the player who clicked a SurfaceGui?

I am making a game, and there is a SurfaceGUI that everyone can see, and when a button is clicked, it brings up a picture. How can I see what player clicked the button? (So I can set permissions, I only want certain people to be able to click and have it actually do something)

I looked around, and saw something about it needing to be in PlayerGUI, which I'm not sure how that would work..

1 answer

As you've already said yourself, and as the Wiki states, in order for you to check who clicked a button on a SurfaceGui, the SurfaceGui itself needs to be in the player's PlayerGui. By doing this, you can get the player by parenting up from the script inside the PlayerGui.

An alternative to this is to place a LocalScript in every player's PlayerGui (StarterGui) which connects the Button1Down event with the SurfaceGui's button in Workspace - This should work as required, though I'd still just go with the first option. You would, again, get the player by getting the LocalPlayer or parenting up to the player.

2 comments

0

I'd have to edit for each player though right? (Wouldn't be hard, I just don't want to do it if I dont have to) And if the SurfaceGui is in the PlayerGui, how would it know what Part to be on?

0

SurfaceGuis have an Adornee property. If you set this property to the part in Workspace that you want it to appear on, it will appear on that part. Changing the ' Face' property will dictate which side of the part the SurfaceGui is rendered on. And, what do you mean by you'd need to edit for each player?

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