SYSTEM
When a player joins, I want the players textcolor to change dependant on their rank in a group. (EXAMPLE) If you have a rank of 255, you get a violet color.
ISSUE
The color of the rank doesn’t change. Also, I’m getting an error on line 33.
lua ServerScriptService.OverheadGui:33: attempt to compare nil <= number
local groupId = 4763170 -- REPLACE 4763170 WITH YOUR GROUP ID
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
wait(1)
if character and character:FindFirstChild("Head") then
local guiClone = script.OverheadGui:Clone()
guiClone.Parent = character.Head
local informationLabel = guiClone.InformationLabel
local playerRank = player:GetRoleInGroup(groupId)
informationLabel.Text = player.Name .. " " .. (playerRank and playerRank or "")
if playerRank == 255 then
informationLabel.TextColor3 = Color3.fromRGB(153, 50, 204) -- violet color
else
local rankColors = {
[1] = Color3.fromRGB(255, 0, 0), -- red
[2] = Color3.fromRGB(255, 153, 0), -- orange
[3] = Color3.fromRGB(255, 255, 0), -- yellow
[4] = Color3.fromRGB(0, 255, 0), -- green
[5] = Color3.fromRGB(0, 0, 255), -- blue
[6] = Color3.fromRGB(128, 0, 128), -- purple
[7] = Color3.fromRGB(255, 255, 255), -- white
[8] = Color3.fromRGB(128, 128, 128), -- gray
[9] = Color3.fromRGB(210, 180, 140), -- tan
[10] = Color3.fromRGB(0, 128, 128), -- teal
[11] = Color3.fromRGB(255, 0, 255), -- magenta
[12] = Color3.fromRGB(128, 0, 0), -- maroon
[13] = Color3.fromRGB(255, 165, 0), -- gold
[14] = Color3.fromRGB(245, 75, 75), -- brick red
[15] = Color3.fromRGB(250, 250, 250), -- pearl
[16] = Color3.fromRGB(0, 0, 0) -- black
}
local colorIndex = playerRank and tonumber(playerRank) <= 17 and tonumber(playerRank) or 16 -- if the rank is higher than 16, use black
informationLabel.TextColor3 = rankColors[colorIndex]
end
end
end)
end)
Any help would be greatly appreciated!