I have a really big script so I won't show you the full script but just a piece of it
local mapsinserverstorage = game:GetService('ServerStorage'):GetChildren() -- Make sure that your maps are in serverstorage. If you have more than just maps in serverstorage, the script might actually choose that.
local chosenmap = mapsinserverstorage[math.random(1, #mapsinserverstorage)]
chosenmap:Clone().Parent = mapstorage
status.Value = "Get ready to be teleported!"
wait(3)
local spawns = chosenmap:WaitForChild('Spawns'):GetChildren()
for _, player in pairs (game.Players:GetPlayers()) do
if player and #spawns > 0 then
local torso = player.Character:WaitForChild('Torso')
local allspawns = math.random(1, #spawns)
local randomspawn = spawns[allspawns]
if randomspawn and torso then
table.remove(spawns, allspawns)
torso.CFrame = CFrame.new(randomspawn.Position + Vector3.new(0,2,0))
Its a piece of a gameround script. The map spawns but the character won't spawn into the map. Ill get the message : infinite yield possible on 'Workspace.InvalidArgvment:WaitForChild("Torso") Any solutions?

1 comment
Local Script or Server Script