Hello! I am having problems with an ID system. Essentially when equipped I want the text label with the players role to turn color. However it just stays black, which is the defult.
local tool = script.Parent.Parent
local Handle = tool.Handle
local Players = game:GetService("Players")
local RS = game:GetService("ReplicatedStorage")
local groupId = 111111 -- Place Holder for this Forum Example
local plr = Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local head = char:WaitForChild("Head")
local billboardGui = RS:WaitForChild("UserInfo"):Clone()
billboardGui.Adornee = head -- Set the Adornee property to the player's head
local textLabel = billboardGui:WaitForChild("Team")
local SurfaceGui = Handle:WaitForChild("SurfaceGui")
local toolTextLabel = SurfaceGui.Main.Description:WaitForChild("Title")
local Image = SurfaceGui.Main:WaitForChild("Player")
tool.Equipped:Connect(function()
if plr:IsInGroup(groupId) then
local roleName = plr:GetRoleInGroup(groupId)
Image.Image = Players:GetUserThumbnailAsync(plr.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size180x180)
toolTextLabel.Text = "Role: " .. roleName
textLabel.Text = "Role: " .. roleName
billboardGui.Parent = head
billboardGui.NameLabel.Text = plr.Name
if roleName == "[Community Member]" then
toolTextLabel.BackgroundColor = BrickColor.new("Black")
elseif roleName == "[Marketing Department]" then
toolTextLabel.BackgroundColor = BrickColor.new("Dark green")
elseif roleName == "[Customer Service Department]" then
toolTextLabel.BackgroundColor = BrickColor.new("New Yeller")
elseif roleName == "[Department Supervisor]" then
toolTextLabel.BackgroundColor = BrickColor.new("Royal blue")
elseif roleName == "[Development Service]" then
toolTextLabel.BackgroundColor = BrickColor.new("Bright orange")
elseif roleName == "[Project Manager]" then
toolTextLabel.BackgroundColor = BrickColor.new("Light purple")
elseif roleName == "[Hub Owner]" then
toolTextLabel.BackgroundColor = BrickColor.new("Gold")
end
end
end)
tool.Unequipped:Connect(function()
if billboardGui.Parent then
billboardGui.Parent = nil
end
end)
According to the documentation, the BackgroundColor property of a GuiObject is deprecated in favor of the BackgroundColor3 property. Try using Color3 to set the BackgroundColor3 instead of BrickColor to set the BackgroundColor
local tool = script.Parent.Parent
local Handle = tool.Handle
local Players = game:GetService("Players")
local RS = game:GetService("ReplicatedStorage")
local groupId = 111111 -- Place Holder for this Forum Example
local plr = Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local head = char:WaitForChild("Head")
local billboardGui = RS:WaitForChild("UserInfo"):Clone()
billboardGui.Adornee = head -- Set the Adornee property to the player's head
local textLabel = billboardGui:WaitForChild("Team")
local SurfaceGui = Handle:WaitForChild("SurfaceGui")
local toolTextLabel = SurfaceGui.Main.Description:WaitForChild("Title")
local Image = SurfaceGui.Main:WaitForChild("Player")
tool.Equipped:Connect(function()
if plr:IsInGroup(groupId) then
local roleName = plr:GetRoleInGroup(groupId)
Image.Image = Players:GetUserThumbnailAsync(plr.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size180x180)
toolTextLabel.Text = "Role: " .. roleName
textLabel.Text = "Role: " .. roleName
billboardGui.Parent = head
billboardGui.NameLabel.Text = plr.Name
if roleName == "Community Member" then
toolTextLabel.BackgroundColor = BrickColor.new("Black")
elseif roleName == "Marketing Department" then
toolTextLabel.BackgroundColor = BrickColor.new("Dark green")
elseif roleName == "Customer Service Department" then
toolTextLabel.BackgroundColor = BrickColor.new("New Yeller")
elseif roleName == "Department Supervisor" then
toolTextLabel.BackgroundColor = BrickColor.new("Royal blue")
elseif roleName == "Development Service" then
toolTextLabel.BackgroundColor = BrickColor.new("Bright orange")
elseif roleName == "Project Manager" then
toolTextLabel.BackgroundColor = BrickColor.new("Light purple")
elseif roleName == "Hub Owner" then
toolTextLabel.BackgroundColor = BrickColor.new("Gold")
end
end
end)
tool.Unequipped:Connect(function()
if billboardGui.Parent then
billboardGui.Parent = nil
end
end)
local tool = script.Parent.Parent
local Handle = tool.Handle
local Players = game:GetService("Players")
local RS = game:GetService("ReplicatedStorage")
local groupId = 111111 -- Place Holder for this Forum Example
local plr = Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local head = char:WaitForChild("Head")
local billboardGui = RS:WaitForChild("UserInfo"):Clone()
billboardGui.Adornee = head -- Set the Adornee property to the player's head
local textLabel = billboardGui:WaitForChild("Team")
local SurfaceGui = Handle:WaitForChild("SurfaceGui")
local toolTextLabel = SurfaceGui.Main.Description:WaitForChild("Title")
local Image = SurfaceGui.Main:WaitForChild("Player")
local roles = {
Community-Member = Brickcolor.new("Black"),
Marketing-Department = Brickcolor.new("Dark green"),
Customer-Service-Department = Brickcolor.new("New yeller"),
Department-Supervisor = Brickcolor.new("Royal blue"),
Development-Service = Brickcolor.new("Bright orange"),
Project-Manager = Brickcolor.new("Light purple"),
Hub-Owner = Brickcolor.new("Gold")
}
tool.Equipped:Connect(function()
if plr:IsInGroup(groupId) then
local roleName = plr:GetRoleInGroup(groupId)
Image.Image = Players:GetUserThumbnailAsync(plr.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size180x180)
toolTextLabel.Text = "Role: "..roleName
textLabel.Text = "Role: "..roleName
billboardGui.Parent = head
billboardGui.NameLabel.Text = plr.Name
for role, colour in roles do
if "["..role:gsub("-", " ").."]" ~= roleName then continue end
toolTextLabel.BackgroundColor3 = colour.Color
end
end
end)
tool.Unequipped:Connect(function()
if billboardGui.Parent then
billboardGui.Parent:Destroy()
end
end)
local tool = script.Parent.Parent
local Handle = tool.Handle
local Players = game:GetService("Players")
local RS = game:GetService("ReplicatedStorage")
local groupId = 111111 -- Place Holder for this Forum Example
local plr = Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local head = char:WaitForChild("Head")
local billboardGui = RS:WaitForChild("UserInfo"):Clone()
billboardGui.Adornee = head -- Set the Adornee property to the player's head
local textLabel = billboardGui:WaitForChild("Team")
local SurfaceGui = Handle:WaitForChild("SurfaceGui")
local toolTextLabel = SurfaceGui.Main.Description:WaitForChild("Title")
local Image = SurfaceGui.Main:WaitForChild("Player")
local roles = {
Community_Member = Brickcolor.new("Black"),
Marketing_Department = Brickcolor.new("Dark green"),
Customer_Service_Department = Brickcolor.new("New yeller"),
Department_Supervisor = Brickcolor.new("Royal blue"),
Development_Service = Brickcolor.new("Bright orange"),
Project_Manager = Brickcolor.new("Light purple"),
Hub_Owner = Brickcolor.new("Gold")
}
tool.Equipped:Connect(function()
if plr:IsInGroup(groupId) then
local roleName = plr:GetRoleInGroup(groupId)
Image.Image = Players:GetUserThumbnailAsync(plr.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size180x180)
toolTextLabel.Text = "Role: "..roleName
textLabel.Text = "Role: "..roleName
billboardGui.Parent = head
billboardGui.NameLabel.Text = plr.Name
for role, colour in roles do
if "["..role:gsub("_", " ").."]" ~= roleName then continue end
toolTextLabel.BackgroundColor3 = colour.Color
end
end
end)
tool.Unequipped:Connect(function()
if billboardGui.Parent then
billboardGui.Parent:Destroy()
end
end)
Replace the localscript with a serverscript, same parent and use this:
local tool = script.Parent.Parent
local Handle = tool.Handle
local Players = game:GetService("Players")
local RS = game:GetService("ReplicatedStorage")
local groupId = 111111 -- Place Holder for this Forum Example
local char
if tool.Parent:IsA("Backpack") then char = tool.Parent.Parent.Character else char = tool.Parent end
local plr = Players:GetPlayerFromCharacter(char)
local head = char:WaitForChild("Head")
local billboardGui = RS:WaitForChild("UserInfo"):Clone()
billboardGui.Adornee = head -- Set the Adornee property to the player's head
local textLabel = billboardGui:WaitForChild("Team")
local SurfaceGui = Handle:WaitForChild("SurfaceGui")
local toolTextLabel = SurfaceGui.Main.Description:WaitForChild("Title")
local Image = SurfaceGui.Main:WaitForChild("Player")
local roles = {
Community_Member = Brickcolor.new("Black"),
Marketing_Department = Brickcolor.new("Dark green"),
Customer_Service_Department = Brickcolor.new("New yeller"),
Department_Supervisor = Brickcolor.new("Royal blue"),
Development_Service = Brickcolor.new("Bright orange"),
Project_Manager = Brickcolor.new("Light purple"),
Hub_Owner = Brickcolor.new("Gold")
}
tool.Equipped:Connect(function()
if plr:IsInGroup(groupId) then
local roleName = plr:GetRoleInGroup(groupId)
Image.Image = Players:GetUserThumbnailAsync(plr.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size180x180)
toolTextLabel.Text = "Role: "..roleName
textLabel.Text = "Role: "..roleName
billboardGui.Parent = head
billboardGui.NameLabel.Text = plr.Name
for role, colour in roles do
if "["..role:gsub("_", " ").."]" ~= roleName then continue end
toolTextLabel.BackgroundColor3 = colour.Color
end
end
end)
tool.Unequipped:Connect(function()
if billboardGui.Parent then
billboardGui.Parent:Destroy()
end
end)
Re-wrote your script and hopefully this will work (It will need to be a server Script instead of a LocalScript though, I did this to keep it simple and straight-foward else you’ll need to use RemoteEvents to replicate the changes to other players):
local groupId = 123456 -- Change this to your actual group id
local replicatedStorage = game:GetService("ReplicatedStorage")
local players = game:GetService("Players")
local debris = game:GetService("Debris")
local tool = script.Parent
local main = tool.Handle.SurfaceGui.Main
local toolTextLabel = main.Description.Title
local image = main.Player
local billboardGui = replicatedStorage.UserInfo
local roles = {
["Guest"] = BrickColor.new("White"), -- Guest means the player isn't a member of your group so it is the default role
["[Community Member]"] = BrickColor.new("Black"),
["[Marketing Department]"] = BrickColor.new("Dark green"),
["[Customer Service Department]"] = BrickColor.new("New Yeller"),
["[Department Supervisor]"] = BrickColor.new("Royal blue"),
["[Development Service]"] = BrickColor.new("Bright orange"),
["[Project Manager]"] = BrickColor.new("Light purple"),
["[Hub Owner]"] = BrickColor.new("Gold")
}
local player
local head
local billboardGuiClone
local function main()
local success, role = pcall(player.GetRoleInGroup, player, groupId)
if success then
billboardGuiClone = billboardGui:Clone()
billboardGuiClone.Adornee = head
billboardGuiClone.Parent = head
billboardGuiClone.Team.Text = role
billboardGuiClone.NameLabel.Text = player.Name
toolTextLabel.Text = role
toolTextLabel.BackgroundColor3 = roles[role].Color
local success, result = pcall(players.GetUserThumbnailAsync, players, player.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size180x180)
if success then image.Image = result end
end
end
tool.Equipped:Connect(function()
if player then main() return end
player = players:GetPlayerFromCharacter(tool.Parent)
head = tool.Parent.Head
main()
end)
tool.Unequipped:Connect(function()
debris:AddItem(billboardGuiClone, 0)
end)
I might have left some things out by mistake, but the core functionality should be there
It would be very helpful to us if you would also include details such as:
Why didn’t our code work
Did you receive any errors in the output when you tested our code, and if so: what was the error?
This would allow us to help you to solve your problem much better
Are you still experiencing the issue where the Gui’s color stays black? If yes, then if possible I recommend you show us a screenshot of the billboardGui and the main Gui and their parents in the Explorer since I’m starting to suspect the problem might be in the way the Gui is designed or structured