In this PART OF A SCRIPT, I want a zombie to teleport to one of the random 6 Spawning positions in the map. Btw i'm holding the positions in a table. The positions are in workspace in a folder (Map) in a model called Field.
zombie1.UpperTorso.CFrame = game:GetService("Workspace").Map.Field:WaitForChild(ZombieTable [math.random(1,6)].CFrame) --ONE LINE, JUST RAN OUT OF SPACE!
It says:
argument missing or nil
on the line of code. Any help would be appreciated.
If the ZombieTable is a table of Vector3Values, you must firstly use .Value to get their value, and secondly put the value inside a CFrame.new(), rather than getting the .CFrame of a Vector3 (which doesn't exist).
However, if the table is of parts that represent the positions, which it most likely is, you are using WaitForChild wrong. WaitForChild takes a string, and you are giving it the CFrame of the part instead. To solve this, you can change it to something like the following, without a WaitForChild:
local ZombieTable = workspace.Map.Field:GetChildren() local ChosenCFrame = ZombieTable[math.random(#ZombieTable)].CFrame zombie1.UpperTorso.CFrame = ChosenCFrame
Make sure the Field map only contains BaseParts.