Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to print the name of the user who pressed a certain button onto a SurfaceGui?

Asked by 9 years ago

Please include the code which you are trying to use, so the community will be better-equipped to help you with your problem.

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.

2 answers

Log in to vote
0
Answered by 9 years ago

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)
0
It's a surfacegui. intrance 50 — 9y
0
Oh, my mistake. The code should work for a SurfaceGui all the same. CoderLeo 50 — 9y
Ad
Log in to vote
-1
Answered by
Hexcede 52
9 years ago
enterbutton.MouseButton1Down:connect(function()
    p = SurfaceGui.Parent.Parent
    SurfaceGui.TextLabel.Text = p.Name
end)

there you go!

Answer this question