I need some answers for my game. So, I have group ranks on my group. And I wanted to make them auto team in the team they belong so for example.
5 People of the rank "Higher Ranked" wanted to join (Random persons so not configured) And 4 people of the rank "Middle Ranked" wanted to join (Random persons so not configured)
And there are 3 teams: "HR" "MR" "Member"
So that the 5 people go to the team HR And the 4 persons to the team "MR"
Automaticly! So not that the names are in the config!
Can someone help me out?
Not something like below
game.Players.PlayerAdded:connect(function(p) -- When a player join if p.Name == "AdminName" then -- Check player's name p.TeamColor = BrickColor.new("Really red") -- Change team end end)
This is an okay script. However, I think you should do this differently. Instead of checking for the player's name, check for his rank on the group instead. To do this, we use the function GetRankInGroup(groupId)
. This will return the player's rank. Take in mind this returns an IntValue
. This does not return the player's Role in the group. The rank is the actual unique number that identifies certain roles. (For example the owner's rank would always be 255)
Anyway... Once you have the rank, use the script below.
-- Variables local groupId = 3028452 -- Change this to your group's ID local HighRank = 200 -- Change this accordingly local MediumRank = 100 -- Change this accordingly local MembersRank = 1 -- Change this to whatever the Member's rank is -- // Teams \\ -- local highRankTeamName = "High Ranks" -- Change this to the HR's Team Name local mediumRankTeamName = "Medium Ranks" -- Change this to the MR's Team Name local membersRankTeamName = "Members" -- Change this to the Member's Team Name function getTeam(teamName) for i,v in pairs(game.Teams:GetChildren()) do if v.Name == teamName then return v end end end game.Players.PlayerAdded:connect(function(player) if player:GetRankInGroup(groupId) >= HighRank then -- Checks for HR+ player.Team = getTeam(highRankTeamName) elseif player:GetRankInGroup(groupId) >= MediumRank then player.Team = getTeam(mediumRankTeamName) elseif player:GetRankInGroup(groupId) == MembersRank then player.Team = membersRankTeamName end end)
The script above checks if the player's rank is Higher or Equal to a high rank or medium rank. If you want the players who are just in that certain rank and not the one above, replace >=
to ==
in the script accordingly
Hope I helped :)