My code is supposed to move each player in a team to a respective spawn point (there is an array of 10 spawn points per team). I load the Character because I want the inventory to reset. It works sometimes, but other times it spawns me in the middle of the map. Why is this occurring?
for i, player in pairs(RedTeam) do
if RedTeam[i] then
character = RedTeam[i].Character
if character then
player:LoadCharacter();
character:FindFirstChild("HumanoidRootPart").CFrame = RedSpawn[i].CFrame
table.remove(RedSpawn,1)
end
end
end
for i, player in pairs(BlueTeam) do
print("hi")
if BlueTeam[i] then
character = BlueTeam[i].Character
if character then
player:LoadCharacter();
character:FindFirstChild("HumanoidRootPart").CFrame = BSpawn[i].CFrame
--local CFra = BSpawn[1].CFrame
--BlueTeam[i]:LoadCharacter(CFra,BlueTeam[i].Character)
table.remove(BSpawn,1)
end
end
end
local RedSpawn = RedSpawnPoints:GetChildren()
local BSpawn = BSpawnPoints:GetChildren()
