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

attempt to call a nil value while i try to get all of the Vector3 type arrays in a table?

Hello scripting helpers community. Im creating a project and got stuck with a nil error when i was trying to get Vector3 type arrays from a table. Can somebody explain how do i add vector3 type values inside a table and also how do i access them? its because i want to get the vector3 types as "for i,v in pairs(arrayList) do...."

so this is part of the script:

local partARRAYS= {}
function paintpart()
	for i,part in pairs(workspace:GetDescendants()) do
		if part:IsA("Part") or part:IsA("UnionOperation") then
			for i = 0 ,part.Size.X ,4 do
				for j = 0,part.Size.Z,4 do
					table.insert(partARRAYS,Vector3.new(i,part.Position.Z+(part.Size.Z/2)+2,j))
					
				end
			end
		end
		if part:IsA("TrussPart") then
			for i = 0 ,part.Size.X ,4 do
				for j = 0 ,part.Size.Y ,4 do
					for k = 0 ,part.Size.Z ,4 do
						table.insert(partARRAYS,Vector3.new(i,j,k))
					end
				end
			end
		end
	end
end
paintpart()
local arrayList  = partARRAYS:GetChildren()

and the error shows "attempt to call a nil value" when i try to access the arrays of the table called "partARRAYS" any help?

1 answer

you cant do GetChildren() on an Table/Array. Im not sure what you are trying to achieve on that line (24)

4 comments

0

So how do i access all the vector3 type indexes in a table?

0

loop over the table ??? or just table.unpack() which would return everything inside a table as a tuple, but do you understand what GetChildren() does ? it returns a table with the children of an instance, but partARRAYS is already a table so i dont understand what you want

0

I have a table full of vector3 type indexes i want to return it so i can use it as "for i,vector3insideTheTable in pair(table) do..." So i guess its loop over the table

0

you can mark this answer as solved now

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