[Fixed] My billboard Gui is not working!

Hello, basically I was trying to use a billboard Gui to make names such as “Scripter”, “Gui-Artist”, and “Builder”. Unfortunately, even though I am the scripter it shows me as a Builder and even for the other people their name does not pop up for their specific role. Here was my script:

script.Parent = game.ServerScriptService
local billboardGui = script.BillboardGui
local playerusername = "dansepehr"
local playerusername1 = "Arksdell"
local playerusername2 = "dansepehr1"
local playerusername3 = "fastboylol101"
local guiTextscripter = "Scripter"
local guiTextbuilder = "Builder"
local guiTextGUI = "Gui-Artist"
local cloneGui = billboardGui:Clone()

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		if player.Name == playerusername or playerusername1 then
			cloneGui.Parent = character.Head
			cloneGui.TextLabel.TextColor3 = Color3.fromRGB(255, 91, 79)
			cloneGui.TextLabel.Text = guiTextscripter
		end
	end)
end)

wait()

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		if player.Name == playerusername2  then
			cloneGui.Parent = character.Head
			cloneGui.TextLabel.TextColor3 = Color3.fromRGB(255, 243, 73)
			cloneGui.TextLabel.Text = guiTextbuilder
		end
	end)
end)

wait()

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		if player.Name == playerusername3 then
			cloneGui.Parent = character.Head
			cloneGui.TextLabel.TextColor3 = Color3.fromRGB(110, 255, 0)
			cloneGui.TextLabel.Text = guiTextGUI
		end
	end)
end)

I do not know how to fix this. If you know a solution please tell me in the comments. Thank you!

4 Likes

Put the local cloneGui = billboardGui:Clone() inside the character Added line
Cause you’ve cloned it only one time, you want it to be cloned everytime they join, simply put the line of code into the characteradded line.

2 Likes

I do not recommend continuing with this method, it looks botched together, use a Dictionary.

Also, do not rely on UserNames as they can be changed, use UserId as they can never change, also clone in the CharacterAdded, not outside as that only makes a single clone

local Players = game:GetService("Players")
script.Parent = game:GetService("ServerScriptService")

local billboardGui = script.BillboardGui

local idRoles = {
	["Scripter"] = {
		Color = Color3.fromRGB(255, 91, 79),
		Ids = {563634634, 36343453}
	},
	["Builder"] = {
		Color = Color3.fromRGB(255, 243, 73),
		Ids = {563634634, 36343453}
	},
	["Gui-Artist"] = {
		Color = Color3.fromRGB(110, 255, 0),
		Ids = {563634634, 36343453}
	}
}

Players.PlayerAdded:Connect(function(player)
	for roleName, info in pairs(idRoles) do
		if not table.find(info.Ids, player.UserId) then
			continue
		end
		local function onCharacterAdded(character)
			local cloneGui = billboardGui:Clone()
			cloneGui.TextLabel.TextColor3 = info.Color
			cloneGui.TextLabel.Text = roleName
			cloneGui.Parent = character.Head
		end
		onCharacterAdded(player.Character or player.CharacterAdded:Wait())
		player.CharacterAdded:Connect(onCharacterAdded)
		break
	end	
end)

3 Likes

I will test if this works! Thank you for the help! (Also this was supposed to be a quick test and I am aware of using the player’s UserId is a smarter choice.)

2 Likes

I’m a complete beginner (sorry) so I have a question. For Ids am I supposed to put the Player’s ID for their specific role? (ex. Arksdell’s ID should be in the scripter IDs table.)

1 Like

Yep, if you’re a scripter, y ou put your UserId in the Ids table for the Scripter’s key

1 Like

What else am I supposed to add in those parts? Like I said I am a beginner ;-;

1 Like

You don’t have to add anything else. The script is fine now.

Oh, but it is constantly bringing up an error whenever I run the script. Is it because my script isn’t in the correct Service? It’s in Workspace right now.

What it is the error? It may be a mistake on my part

You have to put it in ServerScriptService im pretty sure.

2 Likes

GUI SCRIPTING HELP

ItThe code block is also bringing red lines under it:

1 Like

Oh I made a mistake, in the keys I accidentally put a } instead of a ] to close the name of it

local idRoles = {
	["Scripter"} = {
		Color = Color3.fromRGB(255, 91, 79),
		Ids = {563634634, 36343453}
	},
	["Builder"} = {
		Color = Color3.fromRGB(255, 243, 73),
		Ids = {563634634, 36343453}
	}
	["Gui-Artist"} = {
		Color = Color3.fromRGB(110, 255, 0),
		Ids = {563634634, 36343453}
	}
}

Should be

local idRoles = {
	["Scripter"] = {
		Color = Color3.fromRGB(255, 91, 79),
		Ids = {563634634, 36343453}
	},
	["Builder"] = {
		Color = Color3.fromRGB(255, 243, 73),
		Ids = {563634634, 36343453}
	}
	["Gui-Artist"] = {
		Color = Color3.fromRGB(110, 255, 0),
		Ids = {563634634, 36343453}
	}
}
4 Likes

Shouldn’t the “}” have a comma also? Because I thought you were supposed to add it.

1 Like

Yep, that as well, sorry for the mistakes, I am mistake prone when I rush code and dont have an IDE to automate them for me

2 Likes

It’s okay. Thank you for the help also! I just tested it and my name does not show up as builder! :grinning: I will check if it works for my friends too! Thank you again!

1 Like

btw should I just choose your first post as solution or…

2 Likes

You can, I’ll go edit it to fix my mistakes in the mean time

1 Like

Dude i’m sorry I did not reply sooner, I needed my friends to join to see if it works… Unfortunately even though my name shows as Scripter my friends’s Gui does not show as Builder, it does not even show as anything.

I’m not sure if it’s because my actual script is not called script and instead it’s scripterGui. Or because my script is the parent of the BillboardGui or because it’s in ServerScriptService I don’t know… If you can please check my code again… Sorry I didn’t reply to you sooner.

local Players = game:GetService("Players")
script.Parent = game:GetService("ServerScriptService")

local billboardGui = script.BillboardGui

local idRoles = {
	["Scripter"] = {
		Color = Color3.fromRGB(255, 91, 79),
		Ids = {1945845401, 88906002}
		
	},
	["Builder"] = {
		Color = Color3.fromRGB(255, 243, 73),
		Ids = {172947775, 1944420284}
		
	},
	["Gui-Artist"] = {
		Color = Color3.fromRGB(110, 255, 0),
		Ids = {1958489433}
		
	}
}

Players.PlayerAdded:Connect(function(player)
	for roleName, info in pairs(idRoles) do
		if not table.find(info.Ids, player.UserId) then
			continue
		end
		local function onCharacterAdded(character)
			local cloneGui = billboardGui:Clone()
			cloneGui.TextLabel.TextColor3 = info.Color
			cloneGui.TextLabel.Text = roleName
			cloneGui.Parent = character.Head
		end
		onCharacterAdded(player.Character or player.CharacterAdded:Wait())
		player.CharacterAdded:Connect(onCharacterAdded)
		break
	end	
end)
1 Like

I switched my script’s name to “script” by the way…