Still have questions? Join our Discord server and get real time help.
Log in to vote

How to make a team auto assigner using group ranks?

Asked by 3 days ago

I am trying to make it so that if you are a specific rank in my group you will become that sames ranks team in my game. This is the script I've been using so far

local groupid = 7240924
function onPlayerAdded(Player)
    if Player:GetRankInGroup(groupid) == 1 then 
       Player.Team = game.Teams.L1

    elseif Player:GetRankInGroup(groupid) == 2 then
       Player.Team = game.Teams.L2

    elseif Player:GetRankInGroup(groupid) == 3 then
       Player.Team = game.Teams.L3

    elseif Player:GetRankInGroup(groupid) == 4 then
       Player.Team = game.Teams.L4

    elseif Player:GetRankInGroup(groupid) == 5 then
       Player.Team = game.Teams.L5

    elseif Player:GetRankInGroup(groupid) == 6 then
       Player.Team = game.Teams.L6

    elseif Player:GetRankInGroup(groupid) == 7 then
       Player.Team = game.Teams.L7

    elseif Player:GetRankInGroup(groupid) == 8 then
       Player.Team = game.Teams.L8

    elseif Player:GetRankInGroup(groupid) == 9 then
       Player.Team = game.Teams.L9

    elseif Player:GetRankInGroup(groupid) == 10 then
       Player.Team = game.Teams.L10


I am new to scripting so it may be that its just wrong or that I'm putting it in the wrong place. If you could tell me where I need to put the script (workspace, startcharacterscripts, etc.) that would be very helpful.

this is in a game.Players.PlayersAdded event right? PigioGigio 31 — 3d
No it isn't. Should I make an event? jacksworld2808 0 — 3d

1 answer

Log in to vote
Answered by 3 days ago
Edited 3 days ago

Try this script and see the comments

-- Server Script [[ in ServerScriptService ]]
local groupId = 7240924
     local PlayerRank = plr:GetRankInGroup(groupId) -- get the players rank
     local team = game:GetService("Teams"):FindFirstChild("F" .. tostring(PlayerRank)) -- get the team inside of the teams service
     if team and team:IsA("Team") then -- if team is NOT nil and the team Instance is a team
          plr.Team = team -- set the players team
          -- put code in here what happens if there is not a team for the rank.

If this helps, please mark this as a solution!


Answer this question