I am trying to make each player teleport to their respective position on the map when they join, however, it is not working. Is there anything that I'm doing wrong? Script:
game.Players.PlayerAdded:connect(function(player)
print ("[MainScript] Setting up player "..player.Name)
for _,factory in pairs(game.Workspace.Factories:GetChildren()) do
local isOwnedBy = factory.OwnerName
local factoryNumber = factory.FactoryNumber
local spawnPos = factory.SpawnPoint.Position
if isOwnedBy.Value == "" and player.FactoryNumber.Value == 0 then
player.FactoryNumber.Value = factoryNumber.Value
isOwnedBy.Value = player.Name
player.CharacterAdded:connect(function(character)
player.Character:MoveTo(Vector3.new(factory.SpawnPoint.Position) + Vector3.new(0, 1, 0))
end)
end
end
end)

2 comments
I don't know why, but the player is not being moved to the place I specify him.
Where do you want him moved, and where does he move? Does it move to ANY factory?