#My script stopped working

9 messages · Page 1 of 1 (latest)

light marsh
#

I am not getting teamed in the right team

#

.....

quartz abyss
#

so this might work

local Players = game:GetService("Players")
local Teams = game:GetService("Teams")

local Groups = {
    {16728180, "Military Intelligence Command"},
    {15201605, "ASOC"},
    {15201535, "Forces Command"},
    {15201463, "Military Police Corps"},
    {15201399, "TRADOC"},
    {15201355, "Quartermaster Customs"},
}

for _, Team in pairs(Teams:GetChildren()) do
    local Spawns = workspace:FindFirstChild(Team.Name)
    Spawns.BrickColor = Team.TeamColor
    Spawns.Neutral = false
    Spawns.TeamColor = Team.TeamColor
end

Players.PlayerAdded:Connect(function(Player)
    for _, Group in pairs(Groups) do
        if Player:IsInGroup(Group[1]) then
            Player.Team = Teams[Group[2]]
            break
        end    
    end

    if Player:GetRankInGroup(15201263) >= 2 then
        Player.Team = Teams["US Personnel"]
    elseif Player:GetRankInGroup(15201263) < 1 then
        Player.Team = Teams["Civilian"]
    elseif Player:GetRankInGroup(15201263) == 1 then
        Player.Team = Teams["Basic Combat Training"]
    end

    Player.RespawnLocation = workspace:FindFirstChild(Player.Team.Name)
    Player:LoadCharacter()
end)```
#

so i shortened it by almost 6 lines

light marsh
#

can you also make it so if they are in one of these groups

#

local Groups = {
{16728180, "Military Intelligence Command"},
{15201605, "ASOC"},
{15201535, "Forces Command"},
{15201463, "Military Police Corps"},
{15201399, "TRADOC"},
{15201355, "Quartermaster Customs"},
}

#

they get teamed in them instead of US per since their rank will be 2+ and

#

if Player:GetRankInGroup(15201263) >= 2 then
Player.Team = Teams["US Personnel"]

#

will bug it.