How do I get the name of the player that pressed a GUI button. Doesn't seem to hard I just need help. I want the player's name stored in a variable.
COMMUNITY QUESTION
Grab the name of the player that clicked the GUI button?
1 answer
ScreenGui > TextLabel and a Text Button LocalScript Inside TextButton
TextLabel = script.Parent.Parent.TextLabel
script.Parent.MouseButton1Click:connect(function()
-- script here example
p = game.Players.LocalPlayer
p.Character.Torso.Anchored = false
TextLabel.Text = p.Name
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
You should be using a LocalScript when working with GUI's and since a LocalScript is client-side, you always have that players name. game.Players.LocalPlayer.Name