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

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

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)

4 comments

0

Help :(

0

You did not set it's 'Adornee' property [The Parent to show the Billboard].

0

TheAlphaStigma: Adornee is optional -- it assumes the parent if it is a part.

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.

1 answer

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)

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