I'm trying to print the name of a player who pressed the enter button onto a SurfaceGui. Can anyone help me with that? Thanks.
COMMUNITY QUESTION
How to print the name of the user who pressed a certain button onto a SurfaceGui?
2 answers
I am 99% sure this will work.
game.Players.PlayerAdded:connect(function(Player)
local pGUI = Player.PlayerGui
-- Define the ScreenGui in PlayerGui as "local s = pGUI:WaitForChild('[the ScreenGui's name]')
-- Once you define the ScreenGui, define the frame inside it as "local f = s:WaitForChild('[the name of the frame]')
-- You can get any children of any defined Object by using "[variable]:WaitForChild('whatever')"
-- Now, define the button.
local button = f:WaitForChild("[button name]")
-- You will need a TextLabel. Define it.
local textLabel = button:WaitForChild("[textlabel name]")
button.MouseButton1Down:connect(function()
textLabel.Text = "You are " .. Player.Name .. " and you clicked the button!"
end)
end)
enterbutton.MouseButton1Down:connect(function()
p = SurfaceGui.Parent.Parent
SurfaceGui.TextLabel.Text = p.Name
end)
there you go!
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
It's a surfacegui.
Oh, my mistake. The code should work for a SurfaceGui all the same.