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

How may I identify the character that press a Button under SurfaceGui?

So I know in a ScreenGui it's easy to identify the Player especially using the LocalPlayer from the a LocalScript inside of StarterGui but, I was wondering how you would identify a Player under a SurfaceGui and the SurfaceGui is obviously under a Part in the Workspace.... I have tried to use player as an argument however it didn't work out... This is my failed attempt -_- I put this script inside of the TextButton under a Frame inside of a SurfaceGui which is inside of the Part.... If you help me with this I would be very greatful! Thank you :D

script.Parent.MouseButton1Down:connect(function(player)
	print("Hello".. player.Name "in the Club")
end)

Once again thank you for reading my question and I hope you have a solution for my problem!

1 answer

✓ Accepted answer

It's simply not feasible when the SurfaceGui is in Workspace

In order to determine the player that used a SurfaceGui, you have to put the SurfaceGui inside of the PlayerGui and set the Adornee property. There is no practical way to get who did it if the SurfaceGui is in Workspace, and no way to do it if you're attempting to get interaction through a Script (Which is bad practice)

2 comments

0

Well if I put it inside of the PlayerGui the player won't be able to see the SurfaceGui -_-

0

Wrong, dippy. That's why you set the Adornee property.

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