Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

0

Local Script or Server Script

1 answer

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.

2 comments

0

Thanks man it worked!

0

No... just change the waitforchild

This discussion is preserved as it was. New answers, comments, and votes are closed.