Hello again, so im trying to make an Script which get All Children of a folder.
example:
local Folder; --Basicly my path not important
local Values = Folder:GetAllChildren().Value --This i want to correct thx
thank you for help
Hello again, so im trying to make an Script which get All Children of a folder.
example:
local Folder; --Basicly my path not important
local Values = Folder:GetAllChildren().Value --This i want to correct thx
thank you for help
local Values = Folder:GetChildren();
the script doesnt work at me,…
The line of code stores an array of children inside of Values. What else do you want it to do?
You need to learn that a documentation site exists.
Try this!
local folder = script.Parent
local children = folder:GetChildren()
print(children)
I made in player a folder with intvalues in it and i want to get all values of the intvalues cuz there to much values.
cutout of the script:
ds1:SetAsync(plr.UserId, AllIntValuesInsidethefolder.Value)
Well then. You can just modify it using a loop:
local Values = Folder:GetChildren();
local Ints = {};
for _,v in Values do
table.insert(Ints, v.Value);
end
WOW thank you it worked, but now i have the problem that it wont save the values anymore
So, you’re attempting to retrieve the .Value of an IntValue and then store it in a DataStore, right? If that’s the case, consider storing the values as a table directly, rather than storing individual values multiple times. You can achieve this with the following code:
local values = {}
for _, value in next, folder:GetChildren() do
values[value.Name] = value.Value
end
local success, res = pcall(datastore.SetAsync, datastore, ply.UserId, values) -- it's good practice to pcall when you are accessing datastore related stuff.
if success then
print("Data was saved!")
else
print("Data failed to save: "..res)
end
Make sure you are actually loading the values correctly. Check where you use the data to construct the new values and make sure it follows the same format.