Identifying a team by Brick Color is a bad idea, you should use already made teams as they are easier to assign, however you would preferably do this server side like you are right now using the PlayerAdded Event.
Also use team names, they are easier to assign.
This should work ( full code )
local GroupID = 8198781
local Team = ""
function PlayerAdded_Function(...)
local Arguments = { ... }
if Arguments[1]:GetRankInGroup(GroupID) >=1 then
Arguments[1].Team = game:GetService("Teams"):WaitForChild(Team)
end
end
game:GetService("Players").PlayerAdded:Connect(PlayerAdded_Function)
If this doesn't work, result to raw code.
local GroupID = 8198781
local Team = ""
game:GetService("Players").PlayerAdded:Connect(function(self)
if self:GetRankInGroup(GroupID) >=1 then
self.Team = game:GetService("Teams"):WaitForChild(Team)
end
end)
Also some extra help if you wanted to do a team change remote event, just use the player who fired the remote event and check their rank.
Remote Code:
local Remote = game:GetService("ReplicatedStorage"):WaitForChild("Team_Change")
Remote.OnServerEvent:Connect(function(self)
if not self:GetRankInGroup(8198781) >=1 then return end
if self:GetRankInGroup(8198781) >=1 then
self.Team = game:GetService("Teams"):WaitForChild("Team_Name")
end
end)
and then just fire the remote on the client.
2 comments
I am trying to change there teams.
Try changing their team instead?