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)
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.
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.
Every value is a smaller squares position, and it overlaps the smaller squares
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