player.TeamColor Support

What I did:

(BILLBOARD SCRIPT)

local rank = script.Parent

local player = game.Players:GetPlayerFromCharacter(script.Parent.Parent.Parent.Parent)

if player.TeamColor == BrickColor.new(“Black”) then

rank.Text = "National Security, "…player:GetRoleInGroup(13617257)

rank.TextColor3 = Color3.new(0.0705882, 0.0705882, 0.0705882)

end

if player.TeamColor == BrickColor.new(“Crimson”) then

rank.Text = "Sobrejtski Dynasty, "…player:GetRoleInGroup(13623290)

rank.TextColor3 = Color3.new(0.137255, 0.137255, 0.137255)

end

if player.TeamColor == BrickColor.new(“Earth green”) then

rank.Text = "Armed Forces, "…player:GetRoleInGroup(13617195)

rank.TextColor3 = Color3.new(0.0666667, 0.309804, 0)

script.Parent.Parent.Parent.Parent.Disabled = true

end

if player.TeamColor == BrickColor.new(“Earth green”) then

rank.Text = "High Command, "…player:GetRoleInGroup(13617195)

rank.TextColor3 = Color3.new(0.647059, 0.239216, 0.243137)

end

OUTPUT:

image

image

1 Like
local rank = script.Parent

local player = game.Players:GetPlayerFromCharacter(script.Parent.Parent.Parent.Parent.Parent)

if player.TeamColor == BrickColor.new("Black") then

	rank.Text = "National Security, "..tostring(player:GetRoleInGroup(13617257))

	rank.TextColor3 = Color3.new(0.0705882, 0.0705882, 0.0705882)


elseif player.TeamColor == BrickColor.new("Crimson") then

	rank.Text = "Sobrejtski Dynasty, "..tostring(player:GetRoleInGroup(13623290))

	rank.TextColor3 = Color3.new(0.137255, 0.137255, 0.137255)


elseif player.TeamColor == BrickColor.new("Earth green") then

	rank.Text = "Armed Forces, "..tostring(player:GetRoleInGroup(13617195))

	rank.TextColor3 = Color3.new(0.0666667, 0.309804, 0)

	script.Parent.Parent.Parent.Parent.Disabled = true

--elseif player.TeamColor == BrickColor.new("Earth green") then

--	rank.Text = "High Command, "..tostring(player:GetRoleInGroup(13617195))

--	rank.TextColor3 = Color3.new(0.647059, 0.239216, 0.243137)

end

I commented the last portion of the script because they are the same color as the 1 above.

It is caused as the player found is nil, I think this is caused by the path not being correct.
Instead it should be:

-- script      Frame        head
--      RANK         Rank          character
script.Parent.Parent.Parent.Parent.Parent

So the complete script would be:

local rank = script.Parent

local player = game.Players:GetPlayerFromCharacter(script.Parent.Parent.Parent.Parent)

if player.TeamColor == BrickColor.new("Black") then
   rank.Text = "National Security, "..player:GetRoleInGroup(13617257)
   rank.TextColor3 = Color3.new(0.0705882, 0.0705882, 0.0705882)
end

if player.TeamColor == BrickColor.new("Crimson") then
   rank.Text = "Sobrejtski Dynasty, ".. player:GetRoleInGroup(13623290)
   rank.TextColor3 = Color3.new(0.137255, 0.137255, 0.137255)
end

if player.TeamColor == BrickColor.new("Earth green") then
   rank.Text = "Armed Forces, ".. player:GetRoleInGroup(13617195)
   rank.TextColor3 = Color3.new(0.0666667, 0.309804, 0)
   script.Parent.Parent.Parent.Parent.Disabled = true
end

if player.TeamColor == BrickColor.new("Earth green") then
   rank.Text = "High Command, "..player:GetRoleInGroup(13617195)
   rank.TextColor3 = Color3.new(0.647059, 0.239216, 0.243137)
end

By the way I noticed the team color for Armed Forces and High Command is the same.

I suggest to put it in an if statement to check if the player is valid as well:

local rank = script.Parent

local player = game.Players:GetPlayerFromCharacter(script.Parent.Parent.Parent.Parent)

if player then
   if player.TeamColor == BrickColor.new("Black") then
      rank.Text = "National Security, "..player:GetRoleInGroup(13617257)
      rank.TextColor3 = Color3.new(0.0705882, 0.0705882, 0.0705882)
   end

   if player.TeamColor == BrickColor.new("Crimson") then
      rank.Text = "Sobrejtski Dynasty, ".. player:GetRoleInGroup(13623290)
      rank.TextColor3 = Color3.new(0.137255, 0.137255, 0.137255)
   end

   if player.TeamColor == BrickColor.new("Earth green") then
      rank.Text = "Armed Forces, ".. player:GetRoleInGroup(13617195)
      rank.TextColor3 = Color3.new(0.0666667, 0.309804, 0)
      script.Parent.Parent.Parent.Parent.Disabled = true
   end

   if player.TeamColor == BrickColor.new("Earth green") then
      rank.Text = "High Command, "..player:GetRoleInGroup(13617195)
      rank.TextColor3 = Color3.new(0.647059, 0.239216, 0.243137)
   end
else -- if no player
   warn("No player found: " .. script.Parent.Parent.Parent.Parent:GetFullName())
end

I tried all of this but it says:

13:09:19.405 No player found: Workspace.al7tru.Head - Server - Script:27

13:11:05.794 ServerScriptService.RankGUI.Rank.Frame.RANK.Script:5: attempt to index nil with ‘TeamColor’ - Server - Script:5

That’s because you put the script inside of serverscriptservice it should be inside of this directory:
Workspace.al7tru.Head.Rank.Frame.Rank

I can’t put in there when im in studio, that works when I try the game and it’s in my head

Add another .Parent for that one.

To the Local Player or to the warn

local players = game:GetService("Players")

local rank = script.Parent
local character = script:FindFirstAncestorOfClass("Model")
local player = players:GetPlayerFromCharacter(character)

if player.TeamColor == BrickColor.new("Black") then
	rank.Text = "National Security, "..player:GetRoleInGroup(13617257)
	rank.TextColor3 = player.TeamColor.Color
end

if player.TeamColor == BrickColor.new("Crimson") then
	rank.Text = "Sobrejtski Dynasty, "..player:GetRoleInGroup(13623290)
	rank.TextColor3 = player.TeamColor.Color
end

if player.TeamColor == BrickColor.new("Earth green") then
	rank.Text = "Armed Forces, "..player:GetRoleInGroup(13617195)
	rank.TextColor3 = player.TeamColor.Color
end

if player.TeamColor == BrickColor.new("Earth green") then
	rank.Text = "High Command, "..player:GetRoleInGroup(13617195)
	rank.TextColor3 = player.TeamColor.Color
end

First thing that I need to say it’s, color it’s working correctly with the teams, thank you.

But it doesn’t says "National Security, (rank in national security) and it shows this

As I said the color it’s working correctly but do you know how to make the text to say = "National Security (team), (My rank in the group in national security)?

Why is this gui not placed inside the player’s character?

image

THIS script it’s in a TextLabel, the textlabel in a frame, the frame in a billboard gui, the bill board gui in the main script (for the main group) and that script in Workspace

That means it’ll be shared by all players and won’t be unique for each player.

Where can I put the script then?

By the way, the main one it’s this, maybe something interferes:

function onPlayerRespawned(newPlayer)
wait(0.5)
local gui = script.Rank:clone()
gui.Parent=newPlayer.Character.Head
gui.Adornee=newPlayer.Character.Head
local texta=gui.Frame.RANK
texta.Text = (newPlayer:GetRoleInGroup(13601482))
local textb=gui.Frame.Name1
textb.Text = newPlayer.Name
textb.TextColor3 = Color3.new(87, 145, 87)
textb.TextStrokeColor3 = Color3.new(3, 90, 2)
wait(1)
end
function onPlayerEntered(newPlayer)
newPlayer.Changed:connect(function (property)
if (property == “Character”) then
onPlayerRespawned(newPlayer)
end
end)
end
game.Players.PlayerAdded:connect(onPlayerEntered)

It is when I see it when im trying it, maybe do I put in in character scripts?