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

My BillboardGui won't work?

Asked by 9 years ago

So I was trying to make this Billboard GUI to work and I want it to spawn on someone's head. And it didn't work, all it said "local character is a 'nil' value" Here ya go.

local player = game.Players.LocalPlayer
local character = player.Character

local STATS = Instance.new("BillboardGui")
STATS.Parent = player.PlayerGui
STATS.Adornee = character.Head

STATS.Size = UDim2.new(1, 0, 1, 0)

STATS.StudsOffset = Vector3.new(0, 2, 0)

local frame = Instance.new("Frame")
frame.Parent = STATS
frame.Size = UDim2.new(1, 0, 1, 0)
frame.BackgroundTransparency = 0.7
frame.BackgroundColor3 = Color3.new(1, 1, 1)

local text = Instance.new("TextLabel")
text.Parent = frame
text.Position = UDim2.new(0.25, 0, 0.25, 0)
text.Size = UDim2.new(0.5, 0, 0.5, 0)
text.Text = "".. game.Players.Data.Beli.Value

I'm familiar with GUI's but not with a Billboard GUI. Please help.

1 answer

Log in to vote
0
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

The character will not spawn immediately.

Therefore the value from line 2 will be calculated as nil (the script acts before character spawn).

You must wait for the Character to not be nil. Something like this will work:

repeat
    wait();
until player.Character

local character = player.Character
0
:O offbeatpizzalives123 105 — 9y
Ad

Answer this question