I need to find the player after a textbutton in a surfacegui is clicked on, but I don't know how to retrieve the player, unlike a textbutton in a screengui. How can I do this?
✓ ANSWER ACCEPTED
How do I find the player who clicked on a TextButton on a surfacegui?
1 answer
✓ Accepted answer
This is actually pretty simple. All you have to do is put the SurfaceGui inside StarterGui then use a LocalScript to get game.Players.LocalPlayer then Adornee it to the part with this: script.Parent.Parent.Adornee = game.Workspace.Part (Hopefully you should know how to edit it. Change Part to wherever the Part is located in Workspace, and change script.Parent.Parent to wherver the SurfaceGui is, NOT the button.)
Hope this helped and make sure +1 and accept if this worked. If it didnt then please reply and I will answer any questions you need answered.
- NinjoOnline
EXAMPLE I USED:
local player = game.Players.LocalPlayer
script.Parent.Parent.Adornee = game.Workspace.VIPRoom.Frame.Picture
script.Parent.MouseButton1Down:connect(function(skip)
player.leaderstats.Level.Value = 10
player.Character.Humanoid.Health = 0
end)
EDIT
Family Tree:
game
Workspace
VIPRoom
Frame
Picture
StarterGui
SkipGui
Button
LocalScript
The above is just a bit more just incase you get confused.
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Thank you!
np :D Just made a last minute edit just in-case. Thanks for the +1 and accept, hope I helped and explained as much as possible.