Terrain generation algorithm| need help

chunk generation.rbxl (33.8 KB)
My terrain generation system doesnt work. I will really appreciate if anybody can look into it and tell me how i can fix it and even improve it

What are you trying to achieve?

Im prtty sure it’s obvious. I attached the link of a chunk algorithm that i would wish reviewal upon in order to get cues on how i could fix it. It gets the players position relative to a chunk grid and then generates the chunks that are in the players render range/insert the player in the chunks list of players if its already generated. It then checks a table that stored the previous chunks and sees if any of the chunks overlap, if they do so then the a new chunk is not made else it removes the player from the list of players on the said chunks and if the list is empty its deleted. And at the end of the loop the chunks in the current render area of player are becomes the table of last time chunks.On theory it works but once run it has problems deleting the chunks for some reason and inserting multiple player values into the chunks lists of players folder.

after reviewing it i figured out that the problem lies in the position updating part

i got it working by myself in the end thanks for the intention though