So basically I have a user, "greatneil80", the endpoint is "SomeRandomGuy", I want it to retrieve a tree that tells you greatneil80-->RandomGuy-->another random guy-->SomeRandomGuy, as many times until it reaches its endpoint. My issue is, I am finding it hard to create threads of new tables and index them after running the function again, I would love some help, here is my code:
local User = "greatneil80"
local Find = "SomeRandomGuy"
local Tree = {}
local function Got_User()
local Players = game:GetService("Players")
local function iterPageItems(pages)
return coroutine.wrap(function()
local pagenum = 1
while true do
for _, item in ipairs(pages:GetCurrentPage()) do
coroutine.yield(item, pagenum)
end
if pages.IsFinished then
break
end
pages:AdvanceToNextPageAsync()
pagenum = pagenum + 1
end
end)
end
local userId = Players:GetUserIdFromNameAsync(User)
local friendPages = Players:GetFriendsAsync(userId)
local usernames = {}
for item, pageNo in iterPageItems(friendPages) do
table.insert(usernames, item.Username)
end
for _, v in pairs(usernames) do
if v == Find then
print("FOUND USER!!! -->", v)
else
Tree[User] = v
User = v
end
end
end
Got_User()
I really have no clue how to set this up, I'd appreciate help!

1 comment
If anyone managed to come here by chance, I did a take #2 and take #3 along with another remake, #4 with the same concept. The code was somewhat messy but each time I rewrote it, it gave me more options and looked neater than the latter