How to make a 'BillboardGui' over the player's head?

Hello I need some help, I don’t know how to create a ‘BillboardGui’ over the head of the local player, could someone tell me please how to do it :frowning:

i want something like this:

Only local player can see that

If we’re talking locally (Only the player can see), you could probably do something like this in 1 of the local properties?

--Maybe in StarterCharacterScripts
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
--You could put in some parameters if you want to check if a player has a correct requirement
local Billboard = Instance.new("BillboardGUI, Character.Torso")

And then you could configure around with the Billboard’s properties a bit (Size, Text, etc)

1 Like
local Players = game:GetService("Players")
local Client = Players.LocalPlayer or Players.PlayerAdded:Wait()

Client.CharacterAdded:Connect(function(Char)
	local billboardInstance = Instance.new("BillboardGui")		
	billboardInstance.Parent = Char:WaitForChild("Head")
	billboardInstance.StudsOffsetWorldSpace = Vector3.new(0,2.5,0)
	local textLabel = Instance.new("TextLabel")
	textLabel.Parent = billboardInstance
	textLabel.BackgroundTransparency = 1
	textLabel.Text = "Text"
end)
3 Likes

it didn’t worked for me… Should I do it from a script server?

Where did you place the script

I would like to put this billboard on top of the other, so that it looks above

image

ServerScript

local players = game:GetService("Players")
local PLAYER = game.Players.LocalPlayer
local Client = PLAYER.LocalPlayer or PLAYER.PlayerAdded:Wait()

players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		local gui = script.CustomHealthGui:Clone()
		gui.Parent = char.Head

		local mainFrame = gui.MainFrame
		mainFrame.Username.Text = plr.name

		local image = players:GetUserThumbnailAsync(plr.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size100x100)
		mainFrame.UserImageLabel.Image = image

		spawn(function()
			while wait() do
				mainFrame.HealthLabel.Text = tostring(math.floor(char.Humanoid.Health)).."/"..tostring(math.floor(char.Humanoid.MaxHealth))
				mainFrame.HealthBar.Size = UDim2.fromScale((char.Humanoid.Health / char.Humanoid.MaxHealth), 0.4)	
				while wait() do
					mainFrame.HealthLabel.Text = tostring(math.floor(char.Humanoid.Health)).."/"..tostring(math.floor(char.Humanoid.MaxHealth))
					mainFrame.HealthBar.Size = UDim2.fromScale((char.Humanoid.Health / char.Humanoid.MaxHealth), 0.4)
				end	
			end
		end)
		
		Client.CharacterAdded:Connect(function(Char)
			local billboardInstance = Instance.new("BillboardGui")		
			billboardInstance.Parent = Char:WaitForChild("Head")
			billboardInstance.StudsOffsetWorldSpace = Vector3.new(0,3.5,0)
			local textLabel = Instance.new("TextLabel")
			textLabel.Parent = billboardInstance
			textLabel.BackgroundTransparency = 1
			textLabel.Text = "Text"
		end)
		
	end)
end)

Are there any errors in output?

Why do you have a characteradded event inside of a characteradded event and also change client to plr also i thought you wanted this to only be visible to the localplayer

game.Player.LocalPlayer only works in local scripts. If you think about it, ServerScripts would have no idea which player is supposed to be the “Local Player”.

3 Likes

I want the life bar to show on the server but the billboard on the local

Then put in a localscript plus i just tried it and it didn’t work so use this instead.

local Players = game:GetService("Players")
local Client = Players.LocalPlayer or Players.PlayerAdded:Wait()
local Char = Client.Character or Client.CharacterAdded:Wait()
local billboardInstance = Instance.new("BillboardGui")		
billboardInstance.Parent = Char:WaitForChild("Head")
billboardInstance.StudsOffsetWorldSpace = Vector3.new(0,2.5,0)
billboard.Size = UDim2.new(0,100,0,100)
local textLabel = Instance.new("TextLabel")
textLabel.Parent = billboardInstance
textLabel.BackgroundTransparency = 1
textLabel.Size = UDim2.new(0,100,0,100)
textLabel.Text = "Text"
textLabel.TextScaled = true
1 Like

Just gonna-

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()

local GUI = Instance.new("BillboardGui", Character.Head)
GUI.Size = UDim2.new(3, 0, 1, 0)
local TextLabel = Instance.new("TextLabel", GUI)
TextLabel.Text = "This is a local test"
TextLabel.Size = UDim2.new(1,0,1,0)
print("GUI Given to "..Player.Name)

Also make sure to define the Sizes as well, otherwise the UDim2’s will be set to (0,0,0,0)

Yeah was just about to say that when i noticed it wasn’t showing also you need to offset it or it will be in the player’s head.