I have noticed there is no built-in function for getting SpawnLocations from a team.
I can do this:
local function getSpawnsFromTeam(team)
local t = {}
for _, v in pairs(workspace:GetDescendants()) do
if v:IsA("SpawnLocation") and v.TeamColor == team.TeamColor then
table.insert(t, v)
end
end
return t
end
But looping through all instances in the workspace seems kind of unnecessary.
Am I overlooking something? Is there maybe a better way to do this?
If anyone wants to take this to a feature request I would be glad! I sadly can’t post there.
Store all SpawnLocations in a table so you don’t have to visit every instance every time, or tag them and get a table of SpawnLocations using CollectionService
Unfortunately due to the dynamic nature of the spawns (getting cloned in and out of the workspace) it is not possible to keep a static reference to them.