I want to search Data Storages under a spesific folder. Can i use for loop for that or there is another way?
COMMUNITY QUESTION
How can i search everything under a folder?
2 answers
local folderDescs = folder:GetDescendants()
local potentialHit = table.find(folderDescs, SEARCHTERMHERE)
if potentialHit then
print(potentialHit)
end
GetDescendants is really nice but I can’t use it for mine so here’s what I do.
local function scanFolder(Array, folder)
for index, values in pairs (folder:GetChildren)
if values:IsA(“Folder”) then
Array[values.Name] = {}
if values:GetChildren() ~= nil then
scanFolder(Array[values.Name], values)
end
else
Array[values.Name] = values.Value
end
end
return Array
end
And you just pass it the folder you want to search through and the Array or Table you want to JSONEncode India string. Also you can probably do Array[index] instead of values.Name since index is the name of the value lol
So like this
DataStoreArray = scanFolder({}, folderYouWantScannedIn)
This is for storing Folder Data in a Datastore without GetDescendants. If you want to just search the folder for a value GetDescendants is the best. But this way does exactly what get descendants does but you can control it.
1 comment
0
Sorry about the spacing, on phone
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
GetDescendants()