I currently have a system that makes it so that a player is given a team, based on their rank. However, this doesn’t work for spawn points, as they the player initially spawns in before the script actually runs, and therefore, they don’t spawn at the team spawnpoints, and spawn instead directly in the middle. how can I modify my script to fix this?
local Teams = game:GetService("Teams")
local Players = game:GetService("Players")
local function playerAdded(player:Player)
local playerRank = player:GetRankInGroup(33160241)
if playerRank == 2 then
player.Team = Teams:FindFirstChild("Military")
end
if playerRank == 1 or playerRank == 0 then
player.Team = Teams:FindFirstChild("Immigrant")
end
if playerRank == 254 or playerRank == 255 then
player.Team = Teams:FindFirstChild("Premier")
end
end
Players.PlayerAdded:Connect(playerAdded)