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

My BillboardGui in players head won't work, help?!

Asked by
Jurdy 0
10 years ago

I tried to make a billboard show up above players head when they enter the game. But for some reason it says that "Character" is a nil value. Also another problem i thought of is when the player resets the billboard GUI goes away. Please help!

game.Players.PlayerAdded:connect(function(player)
board = Instance.new("BillboardGui",player.Character.Head)
    board.Active = true
    board.AlwaysOnTop = true
    board.Size = UDim2.new(0,10,0,10)
end)
0
Help :( Jurdy 0 — 10y
0
You did not set it's 'Adornee' property [The Parent to show the Billboard]. TheeDeathCaster 2368 — 10y
0
TheAlphaStigma: Adornee is optional -- it assumes the parent if it is a part. BlueTaslem 18071 — 10y
0
Sorry, I did not know. I never saw a code using the 'Billboard' type instance without the 'Adornee' property, so, I thought that was the problem, I'm sorry. TheeDeathCaster 2368 — 10y

1 answer

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

When the player joins, their character hasn't loaded yet. Hence, player.Character is nil (that's where the error you're getting come from).

If you want something to be done each time the player spawns, you could use the CharacterAdded event of the player:

game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        board = Instance.new("BillboardGui", character.Head)
        -- You could still use `player.Character.Head`, but just
        -- `character.Head` is nicer
        board.Active = true
        board.AlwaysOnTop = true
        board.Size = UDim2.new(0, 10, 0, 10)
    end)
end)
Ad

Answer this question