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

Why isn't this BillboardGui displaying content?

So I am making a BillboardGui and I am making a name BillboardGui so, I don't want the BillboardGui to expand when the camera's distance is farther away from the BillboardGui and I thought what if I parent the BillboardGui to the Player when he enters the server and I set the Adornee property to the players head.... However, the BillboardGui gets cloned and parented to the correct place alright... BUT! Nothing is showing above the Character's head -_- Can anyone please help me with this? It would be greatly appreciated Oh! I almost forgot... The BillboardGui has a Frame under it which has a TextLabel under it and the BillboardGui is under a ServerScript inside of ServerScriptService and I am making it clone that and parent it to the PlayerGui and I am trying to make a name Gui above a players head and I don't want the BillboardGui to expand when the camera's distance increases.... Well I think I have elaborated enough for you guys, some help would be appreciated!

OUTPUT ERRORS:

16:42:05.939 - ServerScriptService.Script:6: attempt to index field 'Character' (a nil value)

16:42:05.940 - Stack Begin 16:42:05.940 - Script 'ServerScriptService.Script', Line 6 16:42:05.940 - Stack End

local gui = script:WaitForChild("BillboardGui")
local clone = gui:clone()

game.Players.PlayerAdded:connect(function(player)
	clone.Parent = player.PlayerGui
	clone.Adornee = player.Character.Head
	clone.AbsoluteSize = UDim2.new(0, 200, 0, 50)
	clone.AbsolutePosition = UDim2.new(0,0)
	clone.Frame.TextLabel.Text = player.Name
end)

Thank you for reading all the way :D!

2 answers

✓ Accepted answer

Your Problem

The error code that was returned tells you that player.Character = nil. The most likely cause for this is that the Player was added before the Character. This would mean that player.Character had not been set to any value yet and returns to you nil.

The Solution

We can use an event of Player called CharacterAdded in order to apply the GUI onto the Character as soon as it's created:

local gui = script:WaitForChild("BillboardGui")
local clone = gui:Clone()

game.Players.PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function(character)
		clone.Parent = player.PlayerGui
		clone.Adornee = player.Character.Head
		clone.AbsoluteSize = UDim2.new(0, 200, 0, 50)
		clone.AbsolutePosition = UDim2.new(0, 0, 0, 0)
		clone.Frame.TextLabel.Text = player.Name
	end)
end)

2 comments

0

Is there anyway to make it to where the Gui does not expand when the Camera'sdistance increases?

0

I don't know of any easy way to do it, sorry :(

Here's a way to fix the expanding BillboardGui:

1. Go to your frame or text position for your BillboardGui that you're cloning

2. Change the position to {0,0}{0,-35} (The numbers can be changed to your preference, but leave -35 to any negative number of your choice.)

If this helped, please upvote this.

3 comments

0

Well it won't even appear atm

0

I would recommend you use Instance.new to make your gui.

0

Alright, thank you.

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