Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

BillboardGui won't insert into player?

I wanted the player to have a billboardgui into the player when they join. I can't seem to put one in

function name(player)
local p = player
local head = p.Character:WaitForChild("Head")
local n = Instance.new("BillboardGui",head)
local text = Instance.new("TextLabel",n)
n.Size = UDim2.new(10,0,1,0)
n.StudsOffset = Vector3.new(0,4,0)
n.Name = "Display"
text.Name = "Output"
text.Size = UDim2.new(1,0,2,0)
text.BackgroundTransparency = 1
text.Text = p.Name
text.TextStrokeTransparency = 0
text.TextTransparency = 0
text.TextColor3 = Color3.new(255,255,255)
text.TextStrokeColor3 = Color3.new(0,0,0)
end
game.Players.ChildAdded:connect(name)

1 answer

Okay, your problem was Character was returning nil. Unfortunately, I couldn't find a way to make it work. Instead I simply made a value that finds the characters name in workspace.

Code:

local playername

game:GetService("Players").PlayerAdded:connect(function(player)
playername = player.Name
local head = game.workspace:WaitForChild(playername):WaitForChild("Head")
local n = Instance.new("BillboardGui", head)
local text = Instance.new("TextLabel", n)
n.Size = UDim2.new(10,0,1,0)
n.StudsOffset = Vector3.new(0,4,0)
n.Name = "Display"
text.Name = "Output"
text.Size = UDim2.new(1,0,2,0)
text.BackgroundTransparency = 1
text.Text = player.Name
text.TextStrokeTransparency = 0
text.TextTransparency = 0
text.TextColor3 = Color3.new(255,255,255)
text.TextStrokeColor3 = Color3.new(0,0,0)
end)

This works just as well, except it adds 1 line of code to it.

2 comments

0

Doesn't work... .3.

0

Put it in a normal script that's in Workspace.

This discussion is preserved as it was. New answers, comments, and votes are closed.