Tables not working

Hello, im trying to make a maze generator but i got stuck on this error.

local function createPart(px, py, pz, x, y, z, color)
    local part = Instance.new("Part")
	part.Anchored = true
	part.BrickColor = color
	part.Position = Vector3.new(px, py, pz)
	part.Size = Vector3.new(x, y, z)
	part.TopSurface = Enum.SurfaceType.Smooth
	part.Parent = workspace
	
	return part
end

local mazeX = 40
local mazeZ = 40
local visitedCells = 0

local maze = {}
maze.X = {}
maze.Z = {}

for i = 1, 40 do
    maze.X = i
	maze.Z = i
end

print(maze[X][Z])

local stack = {}

for x = 1, mazeX, 5 do
    for z = 1, mazeZ, 5 do
	    if maze[X][Z] == "visited" then
		    createPart(x, 3, z, 5, 1, 5, BrickColor.new("Deep blue"))
		else
		    createPart(x, 3, z, 5, 1, 5, BrickColor.new("Black"))
		end
	end
end

How do i fix this?