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.
I am 99% sure this will work.
01 | game.Players.PlayerAdded:connect( function (Player) |
02 | local pGUI = Player.PlayerGui |
03 | -- Define the ScreenGui in PlayerGui as "local s = pGUI:WaitForChild('[the ScreenGui's name]') |
04 | -- Once you define the ScreenGui, define the frame inside it as "local f = s:WaitForChild('[the name of the frame]') |
05 | -- You can get any children of any defined Object by using "[variable]:WaitForChild('whatever')" |
06 | -- Now, define the button. |
07 | local button = f:WaitForChild( "[button name]" ) |
08 | -- You will need a TextLabel. Define it. |
09 | local textLabel = button:WaitForChild( "[textlabel name]" ) |
10 |
11 | button.MouseButton 1 Down:connect( function () |
12 | textLabel.Text = "You are " .. Player.Name .. " and you clicked the button!" |
13 | end ) |
14 | end ) |
1 | enterbutton.MouseButton 1 Down:connect( function () |
2 | p = SurfaceGui.Parent.Parent |
3 | SurfaceGui.TextLabel.Text = p.Name |
4 | end ) |
there you go!