Help with teleport script

hey there, im making a game where i need to teleport all players to one position, so they can all reach the map and fight, but its not working or giving any sort of warning in the output

heres my code:

local Maps = game.ReplicatedStorage.Maps

local CandyLand = Maps.CandyLand

local Map = CandyLand:Clone()
Map.Parent = workspace

for i,v in pairs(game.Players:GetChildren()) do
	v.Character.HumanoidRootPart.Position = Map.Spawn.Position
end

i don’t know how to fix this, i thought

game.Players.PlayerAdded:Connect(function(player)

would work but obviosly whenever a player joins, everyone will be teleported to the map

thanks in advance

I think you should use :MoveTo() to move the whole model. Let me see.

Try :

       '''
  for _, player in pairs(game.Players:GetChildren()) do
      player.Character.HumanoidRootPart.CFrame = Map.Spawn.CFrame
  end

I don’t think :MoveTo would be good for this…

this script is in ServerScriptService, if i move the root part, the whole player moves

For reference:

function onTouch(part)
if part.Parent.Humanoid ~=nil then
part.Parent:MoveTo(script.Parent.Parent.tp.Position)
script.Parent.Parent.tp.Script.Disabled = true 
wait(2)
script.Parent.Parent.tp.Script.Disabled = false
end
end
script.Parent.Touched:connect(onTouch)

This is my script I use for teleporting players. You could edit some of the stuff and see if it works.

Um, try my script below, it works for me…

        '''
  for _, player in pairs(game.Players:GetPlayers()) do
       player.Character.HumanoidRootPart.CFrame = Map.Spawn.CFrame
  end

Just a note, you should be using GetPlayers() instead of GetChildren(), since that is what the whole purpose of GetPlayers is. On the one-off chance something else that is not a player gets into your players folder, using GetPlayers will still function the same, but GetChildren would error.

True, I will fix that, thanks for the notice!