Answered by
4 years ago Edited 4 years ago
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.
1 | local spawns = chosenMap.Spawns:GetChildren() |
2 | for _, player in pairs (game:GetService( "Players" ):GetPlayers()) do |
3 | local selectedPart = spawns [ math.random( 1 , #spawns) ] |
4 | player.Character:MoveTo(selectedPart.Position) |
Also you should use SetPrimaryPartCFrame()
to get both position and orientation of the player.