Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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.

2 comments

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

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..

1 answer

✓ Accepted answer

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).

2 comments

0

That seems like an good idea

0

Now I just have to find a way to save each value

This discussion is preserved as it was. New answers, comments, and votes are closed.