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

BillboardGui won't insert into player?

Asked by
yoshi8080 445 Moderation Voter
8 years ago

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

Log in to vote
0
Answered by 8 years ago

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.

0
Doesn't work... .3. yoshi8080 445 — 8y
0
Put it in a normal script that's in Workspace. User#9949 0 — 8y
Ad

Answer this question