Here's the code:
local spawns = chosenMap.Spawns:GetChildren() for _, Player in next, game:GetService("Players"):GetPlayers() do local SelectedPart = spawns[math.random(1, #spawns)] Player.Character:MoveTo(SelectedPart.Position) end
When I test the game with multiple players, everyone gets teleported to the same part, there are four possible part teleportations in total. Help would be appreciated.
Right, you're on the right track, but I suggest using an in pairs loop instead of a next for loop. It loops through tables, and it gets the value, and that's what you need. It is recommended you use an in pairs loop as it is more efficient.
local spawns = chosenMap.Spawns:GetChildren() for _, player in pairs(game:GetService("Players"):GetPlayers()) do local selectedPart = spawns[math.random(1, #spawns)] player.Character:MoveTo(selectedPart.Position) end
Also you should use SetPrimaryPartCFrame()
to get both position and orientation of the player.