Player's Username in a BillboardGui

I’m currently working on a feature for a project which requires the Username of a Player to appear in a BillboardGui.

Example:
A player would click a button (using a ClickDetector). Upon doing this the username of the player who clicked the button would appear as the Text in a BillboardGui.

local ClickDetector = script.Parent

ClickDetector.MouseClick:Connect(function()

   ???

end)

Does anyone know how I would make the Player’s username display in the BillboardGui?

Thanks

MouseClick returns the palyer who clicked the button,

ClickDetector.MouseClick:Connect(function(player)
    print(player.Name)
    --Code down there
end)

Afterwards, you would reference the BillboardGui, and change a Textlabel’s text to the name of the player

4 Likes

You could make a variable for the player, and make it so it changed the billboards text to the players name that clicked on it.

1 Like

Some thing like this would work. You can change stuff like the billboard gui offset in the billboard gui properties to make it slightly above the players head

local ClickDetector = script.Parent

ClickDetector.MouseClick:Connect(function(player)

    local billboardGui = script.BillboardGui -- Change to the location of the billboard gui
    billboardGui.TextLabel.Text = player.Name
    billboardGui.Parent = player.Character.Head

end)
2 Likes