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

How do I make a data storage save values inside a folder?

Asked by 6 years ago

I've tried many ways to do this and none of the scripts worked. Such as like:

for i,v in pairs(player:WaitForChild("PlayerSkins"):GetChildren(child)) do
v.Name = child.Name
v.Value = child.Value
end

That and other methodes that didn't work! I'm getting frustrated since I'm looking for a solution for 1 entire day. If someone knows how to save values inside a folder and load them when a player enters I would be really really gratefull. For real, help someone.

0
What are you trying to accomplish? Do you want to save a player's skins? Also, GetChildren() doesn't take an argument I think AdministratorReece 193 — 6y
0
I'm trying to save ALL the values in a folder and I can't figure out how to do that, I guess that you can't use the for i loop to loop through the values inside and save them since they have no especific name.. wilsonsilva007 373 — 6y

1 answer

Log in to vote
3
Answered by 6 years ago

There are guides telling you the basics of how to work with DataStores, so I will only show you how to convert a list of IntValues into something you can save:

local values = {}
for i, child in ipairs(player:WaitForChild("PlayerSkins"):GetChildren()) do
    values[i] = {Name=child.Name, Value=child.Value}
end
--You should now be able to save 'values'

--When you load it, you might do something like this. Say you've loaded it into 'values':
for i, v in ipairs(values) do
    local name, value = v.Name, v.Value
    --You must now convert the name/value into a PlayerSkins. Of course, you can save/load other information besides Name/Value, just modify the save/load loops
end

Just make sure that every table you save is either an array (uses only consecutive integer keys -- that is, no holes/nil values in the middle) OR uses only string keys (I can't recall if it can have any non-integer keys, but you can test this yourself if you ever need it).

0
That seems like an good idea wilsonsilva007 373 — 6y
0
Now I just have to find a way to save each value wilsonsilva007 373 — 6y
Ad

Answer this question