Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to fix Infinite yield possible on 'Workspace.InvalidArgvment:WaitForChild("Torso")?

Asked by 6 years ago

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?

0
Local Script or Server Script hellmatic 1523 — 6y

1 answer

Log in to vote
0
Answered by
522049 152
6 years ago

One possible error is that the character is an r15 rig, and r15 rigs don't have a torso. You could try changing 'Torso' to 'HumanoidRootPart' and see if that works.

0
Thanks man it worked! InvalidArgvment 0 — 6y
0
No... just change the waitforchild User#20388 0 — 6y
Ad

Answer this question