Make it so players get teamed depending on rank before they join

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want the player to get teamed based on their rank before they join in, so they spawn at the correct spawn pad…
  2. What is the issue? Include screenshots / videos if possible!
    When joining in, the player isn’t spawning at the correct spawn pad. I am 99% sure this is because they spawn before they get teamed.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve tried different scripts and putting the script in the starter player.
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local groupId = 14289900
local gPlayers = game:GetService("Players")
gPlayers.PlayerAdded:Connect(function(player)
	local playerTeam = ""
	local playerRank = player:GetRankInGroup(groupId)
	
	if playerRank >= 2 then
		playerTeam = "U.S Personnel"
	elseif playerRank == 1 then
		playerTeam = "BCT"
	elseif playerRank == 0 then
		playerTeam = "Citizen"
	end

		player.Team = game.Teams[playerTeam]
end)

Use LoadCharacter:

--//Services
local Players = game:GetService("Players")
local Teams = game:GetService("Teams")

--//Controls
local groupId = 14289900

--//Functions
Players.PlayerAdded:Connect(function(player)
	local playerTeam = nil
	
	if player:IsInGroup(groupId) then
		local playerRank = player:GetRankInGroup(groupId)
		
		if playerRank >= 2 then
			playerTeam = "U.S Personnel"
		elseif playerRank == 1 then
			playerTeam = "BCT"
		elseif playerRank == 0 then
			playerTeam = "Citizen"
		end	
	else
		playerTeam = "Citizen"	
	end

	player.Team = Teams:WaitForChild(playerTeam)
	player:LoadCharacter()
end)
1 Like