Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How can i search everything under a folder?

Asked by 4 years ago

I want to search Data Storages under a spesific folder. Can i use for loop for that or there is another way?

0
GetDescendants() DeceptiveCaster 3761 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago
local folderDescs = folder:GetDescendants()

local potentialHit = table.find(folderDescs, SEARCHTERMHERE)

if potentialHit then
    print(potentialHit)
end
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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.

0
Sorry about the spacing, on phone SethHeinzman 284 — 4y

Answer this question