I made a rank script that is supposed to show your group rank over your head in a certain color. It shows your rank number instead of the name and it isn't colored. Please help me fix this script since i don't know what is wrong with it. I have tried multiple things like changing role to rank, keeping it just if role == "rank name" or just if rank == rank number. There are no errors in the console.
game.Players.PlayerAdded:connect(function(plr) plr.CharacterAdded:connect(function(char) local rank = plr:GetRankInGroup(1148703) local role = plr:GetRoleInGroup(1148703) local color = Color3.new(255/255, 255/255, 255/255) if rank == 0 and role == "Guest" then role = "Guest" color = color3.new(255/255, 255/255, 255/255) elseif rank == 10 and role == "Member" then role = "Member" color = Color3.new(255/255, 255/255, 255/255) elseif rank == 145 and rank == "Abuse Reporter" then role = "Abuse Reporter" color = Color3.new(117/255, 69/255, 71/255) elseif rank == 155 and role == "Trial-Moderator" then role = "Trial-Moderator" color = Color3.new(0/255, 0/255, 0/255) elseif rank == 165 and role == "Moderator" then role = "Moderator" color = Color3.new(52/255, 117/255, 0/255) elseif rank == 175 and role == "Head-Moderator" then role = "Head-Moderator" color = Color3.new(255/255, 149/255, 0/255) elseif rank == 185 and role == "Supervisor" then role = "Supervisor" color = Color3.new(17/255, 0/255, 255/255) elseif rank == 195 and role == "Manager" then role = "Manager" color = Color3.new(117/255, 107/255, 255/255) elseif rank == 205 and role == "Administrator" then role = "Administrator" color = Color3.new(54/255, 14/255, 255/255) elseif rank == 215 and role == "Head-Administrator" then role = "Head-Administrator" color = Color3.new(19/255, 255/255, 7/255) elseif rank == 216 and role == "Chief Staff Officer" then role = "Chief Staff Officer" color = Color3.new(139/255, 1/255, 132/255) elseif rank == 217 and role == "Chief Operational Officer" then role = "Chief Operational Officer" color = Color3.new(254/255, 255/255, 180/255) elseif rank == 218 and role == "Chief Executive Officer" then role = "Chief Executive Officer" color = Color3.new(1/255, 74/255, 74/255) elseif rank == 225 and role == "Developer" then role = "Developer" color = Color3.new(138/255, 138/255, 138/255) elseif rank == 235 and role == "Co-Owner" then role = "Co-Owner" color = Color3.new(8/255, 255/255, 239/255) elseif rank == 245 and role == "Group Owner" then role = "Group Owner" color = Color3.new(255/255, 8/255, 235/255) elseif rank == 255 and role == "Mod King -Owner-" then role = "Mod King -Owner-" color = Color3.new(255/255, 0/255, 0/255) end print(plr.Name.." just joined with rank '"..role.."'") if rank ~= "Guest" then local rankd = game.ServerStorage.Rank:Clone() rankd.Parent = char.Head rankd.TextLabel.Text = rank rankd.TextLabel.TextColor3 = color end end) end)
Assuming that rankd is a BillboardGui, and this is a server sided (regular) script this should work:
ranks = { [0] = Color3.new(1,1,1), [10] = Color3.new(1,1,1), [145] = Color3.new(117/255,69/255,71/255), [155] = Color3.new(0,0,0), [165] = Color3.new(52/255,117/255,0/255), [175] = Color3.new(1,149/255,0), [185] = Color3.new(17/255,0,1), [195] = Color3.new(117/255,107/255,1), [205] = Color3.new(54/255,14/255,1), [215] = Color3.new(19/255,1,7/255), [216] = Color3.new(139/255,1/255,132/255), [217] = Color3.new(254/255,1,180/255), [218] = Color3.new(1/255,74/255,74/255), [225] = Color3.new(138/255,138/255,138/255), [235] = Color3.new(8/255,1,239/255), [245] = Color3.new(1,8/255,235/255), [255] = Color3.new(1,0,0) } game.Players.PlayerAdded:connect(function(plr) local rank = plr:GetRankInGroup(1148703) local role = plr:GetRoleInGroup(1148703) if rank ~= 0 then local rankd = game.ServerStorage.Rank:Clone() repeat wait() until plr.Character rankd.Parent = plr.Character.Head rankd.TextLabel.Text = role rankd.TextLabel.TextColor3 = ranks[rank] end end)
Your mistake was most likely in line 59 where you were trying to compare rank to role. Rank is the number of the rank, and role is the name of the rank. Furthermore, I have taken the freedom to much simplify the code by using a table to store the different colours of the ranks, and to use the role that Roblox provides us rather than trying to manually set the role again.