Hello,
I was wondering how to get the player who clicked a button in a SurfaceGui. A LocalScript doesnt work since its not a descendant of the player or their character. Any ideas?
You can use a LocalScript, by just putting the LocalScript in the PlayerGui and making it look for game.Workspace.MyScreen
.
This would work well if there was only one particular Surface that you care about (e.g., this one screen in the lobby, etc), though using loops you could also just include any number of others in the workspace.
e.g.
local surface = workspace.ScreenMain.SurfaceGui local button = surface.Frame.TextButton local player = game.Players.LocalPlayer function clicked() print(player, "clicked") end button.MouseButton1Down:connect(clicked)