Part Generation Issue

Hey, I’m trying to print the positions around a player once, but they start to repeat. Not sure what’s causing this, help?

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		while true do
			local root3 = char.Torso.Position
			for x = -5,5 do
				for z = -5,5 do
					for _, e in ipairs(workspace.Chunks:GetChildren()) do
						local V = Vector3.new(math.floor(root3.X)+x*3,0,math.floor(root3.Z)+z*3)
						if e.Value ~= V then
							local val = game.Workspace.Chunks.ChunkVec:Clone()
							val.Parent = game.Workspace.Chunks
							val.Value = V
							print(V)
						break
						end
					end
				end
			end
			wait(3)
		end
	end)
end)

You are using a while true loop, could that not be the reason that it’s repeating?

It gets every coordinate around the player forever, and if it finds a value in a list of values with a that coordinate, it skips it. The problem is that whenever the while loop repeats, it doesn’t check the value and redoes them all.

Gen.rbxl (29.6 KB)

I don’t understand what you’re trying to achieve.

Capture
I’m trying to make a square around the player based off of coordiantes around the player. The issue is that in every while true loop, remakes another square inside of the original, where it’s meant to not overlap and only fill spaces that are not filled.
Capture
Every value is a smaller squares position, and it overlaps the smaller squares
Capture

Do you want the square only spawn once on the player or infinitely?

Capture

the 1st square generates under the player, while the 2nd square is meant to fill like this picture, but it overlaps the first square, like infinite terrain

What do you meant by overlap? It looks like both of the squares in the picture are overlapping already.