game.Players.PlayerAdded:connect(function(player) -- function is called when player joins game
if player:GetRankInGroup(4980928) >= 238 then --checks if players rank in 2671856 is greater than or equal to 8
player.Team = "United States Military" -- sets players team to officers
elseif player:GetRankInGroup(4980928) < 238 then -- checks if players rank in 2671856 is smaller than 8
player.Team = "Basic Combat Training" -- sets players team to unlisted
else -- if player meets none of the above conditions
player.TeamColor = "Visitors" -- set team to visitors
end
end)
game:GetService("Players").PlayerAdded:Connect(function(Player)
if Player:IsInGroup(4986262) then
Player.TeamColor = BrickColor.new("Maroon")
else
Player.TeamColor = BrickColor.new("Parsley green")
end
end)
COMMUNITY QUESTION
Help what is wrong in this group/team changer code?
1 answer
game.Players.PlayerAdded:connect(function(player)
if player:GetRankInGroup(4980928) >= 238 then
player.Team = game.Teams["United States Marines"]
elseif player:GetRankInGroup(4980928) < 238 then
player.Team = game.Teams["Basic Combat Training"]
else
player.Team = game.Teams["Visitor"]
end
end)
You can change it to an object value instead of a string value when changing the player.Team
1 comment
0
Also, you don't need to change the teamcolor.
This discussion is preserved as it was. New answers, comments, and votes are closed.

6 comments
Use the lua code block so we can understand it, please.
Sorry, Fixed.
Why are there two Playeradded Events and why doesnt the first one have an end?
I had just mixed it together, Thats why there was 2, Would that break the script?
yes
Oh, Okay thanks how would I replace that?