I am making a game where instead of the boring nametags above the players heads I want a custom one which has random colors and goes above the persons head. I tried and I can't seem to get it to work. Can anybody help me? Thanks!

Here is the code:

local colors = {
	Color3.fromRGB(0, 100, 200), -- Blue
	Color3.fromRGB(200, 0, 0), -- Red
	Color3.fromRGB(0, 200, 0), -- Green
}

local Players = game:GetService("Players")

local gui = game.ServerStorage.BillboardGui

local clone = gui:Clone()

Players.PlayerAdded:Connect(function(player)
	gui:Clone()
	clone.Parent = game.Workspace[player]
	local newgui = game.Workspace[player]:WaitForChild("BillboardGui")
	newgui.TextLabel.Text = player.name
	newgui.TextLabel.TextColor = Color3
	newgui.TextLabel.TextColor3 = colors[math.random(1, #colors)]
wait()
script:Destroy()
end)

2 comments

0

Wait for character to be added in game, then add the nametag to his head. I also recommend you search how to make nametags on youtube.

0

ok, that fixed it, Thanks!