When i test my game with multiple fake players, this shows up in the output:
ServerScriptService.MapChanger/Intermission:26: attempt to index nil with 'MoveTo'
MapChanger/Intermission is the name of my script, here is the block of code:
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
One possible reason I think this is occurring may have to do with players not being completely loaded in when they join the game. Overall, it's really annoying and when the error occurs, the game can no longer function as this is the main game runner.
Merely unrelated, but I thought I'd bring it up anyway, was a suggestion by others that I should change MoveTo to setPrimaryPartCFrame() but I cannot seem to get it to work.
To some, this block may seem familiar because I posted here merely a day ago, I thought it was worth bringing up so here I am. To anyone that recognises me or this script, sorry for my impatience, thank you.

3 comments
The block looks good so far, ill test it out when i get the time again, thanks. What’s your input on setPrimaryPartCFrame() btw?
MoveTo does overlap checking, meaning that if you were to try and use it to teleport the player into a large brick, it would shift the player up so it does not get stuck inside. SetPrimaryPartCFrame would place them inside of the block, not caring about overlaps.
Okay so I still get this error when playtesting, it only occurs while someone's player is still loading in and joining. Additionally, adding Player.CharacterAdded:Wait() at the beggining just seems to stall forever, please help with how I should lay the script out.