Table.insert not working

You can write your topic however you want, but you need to answer these questions:
I would like to store the parts that are in the chunk into a table using table.insert but it stores nothing.


local Chunk = {}
Chunk.__index = Chunk

function Chunk:Create()
	
	local chunk = {
		instances = {}
	}

	setmetatable(chunk,Chunk)
	
	
	local Grid = {}

	for x = 0, Chunk_Size do
		Grid[x] =  {}
		for z = 0, Chunk_Size do

			local Height = getHeight(x,z)

			Grid[x][z] = Vector3.new( x * 5 , -math.round(Height * Amplitude) , z * 5 )

		end
	end

	for x = 0, Chunk_Size-1 do
		for z = 0, Chunk_Size-1 do
			local a = Grid[x][z]
			local b = Grid[x+1][z]
			local c =  Grid[x][z+1]
			local d = Grid[x+1][z+1]

			if a.Y == b.Y and c.Y == d.Y and a.Y == c.Y then

				local Square = draw_Square(d)
				table.insert( chunk.instances, Square)
				triangle_count += 2
			else
				local Triangle_A , Triangle_B = draw_Triangle(a,b,c)
				local Triangle_C , Triangle_D = draw_Triangle(b,c,d)
				table.insert( chunk.instances, Triangle_A )
				table.insert( chunk.instances, Triangle_B )
				table.insert( chunk.instances, Triangle_C )
				table.insert( chunk.instances, Triangle_D )
				triangle_count += 4
			end
		end
		game:GetService("RunService").Heartbeat:Wait()
	end
	print(chunk.instances)
	return chunk
end

function Chunk:Destroy()
	for index, instance in ipairs(self.instances) do
		print(instance)
		instance:Destroy()
	end
end

return Chunk

What are draw_Triangle and draw_Square? Are you sure they’re returning anything.

1 Like

omg no(extra characters because roblox)

Thanks for reminding me how stupid I am