Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why is my group team script not giving the people in my group their specific team?

My group team script is not working...

I used the print method to check if there are any errors, and their are none.

I don't know what possibly could be the problem.

local TheNavy = 8198781

function Added(plyr)
	if plyr:GetRankInGroup(TheNavy) >=1 then
		plyr.TeamColor = BrickColor.new("Really black")
	end
end
game.Players.PlayerAdded:Connect(Added)

2 comments

0

I am trying to change there teams.

0

Try changing their team instead?

2 answers

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 = "" -- put your team name here o_o

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 = "" -- put your team name here again?

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") 
-- assuming your remote is called Team_Change

Remote.OnServerEvent:Connect(function(self)
  if not self:GetRankInGroup(8198781) >=1 then return end -- serverside check

  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.

Try doing this instead?

plyr.Team = game:GetService("Teams")["Your team name here"]

This discussion is preserved as it was. New answers, comments, and votes are closed.