Going to write out a small snippet in order to help explain my question.
local chosen = {}
local players = game.Players:GetPlayers()
for _,player in pairs(players) do
table.insert(chosen, player)
end
Then, after all is said and done, I loop through the Chosen table and assign each player to the – for sake of explanation – “Playing” team. When I go to respawn each player, however, I notice that each user spawns in the same location, despite the fact that I’ve a multitude of spawns throughout the map.
Realistically, I want each player to spawn at their own spawn location. Each spawn should be occupied by one player, not two, not three, not four.
Is there a way for me to make that work? Because I keep ending up with two players spawning at the same location.
Here is the script, i have explained everything so you wouldn’t get confused :
local Spawners = game.Workspace:FindFirstChild("Spawners"):GetChildren() --// This should be a group, containing the BaseParts so players can get teleported in one of them. It will return a table with the spawners
local Players = game:GetService("Players"):GetPlayers() --// This will return a table with all the players.
for _, Player in pairs(Players) do --For each player, it will do...
local Char = Player.Character or Player.CharacterAdded:Wait() --// It will get the Character of the Player.
local RandomSpawn = Spawners[math.random(#Spawners)] --// It will get a random spawner.
Char:SetPrimaryPartCFrame(RandomSpawn.CFrame) --// The Character's Humanoid Root Part's CFrame will be set as the RandomSpawn CFrame, aka teleport.
table.remove(Spawners, table.find(RandomSpawn)) --// The thing you wanted, this will remove the spawner that was selected from the table Spawners, so the random logic thing will not get it anymore.
end
If you get any issue or an error you can tell me and i might fix it. Thanks for reading.