Hello! how can I make a for loop that allows me to store values into a table ex:
(these are string values)
I want to loop through the string values and store them in a table (not the instance the value of the string values) sort of like this:
--this is edited for simplicity
local plrPets = {}
for i,pet in pairs(PlayerValues:GetChildren()) do
--somehow store THE VALUE of "pet" to save in datastore in a table
end
I’ve tried
table.insert (plrPets, pet.Value)
but obvoiusly that won’t work so I’m asking here.
Help would be Very Epic Gamer!
Why won’t it work? Whats wrong about it?
I tried and nothing comes out of it
You can store them as a dictionary format, with the keys being the names of the values, and the values being the value of the ValueObject:
local dictionary = {}
for _, value in pairs(PlayerValues:GetChildren()) do
dictionary[value.Name] = value.Value;
end
How did u know if it worked or not?
But how did she know if it got inserted into the table? Whats the code she used
Hm, i didn’t thought of that, she/he could loop through the table, and print what is inside of it.
Or they could add a breakpoint after the for loop, and look at the dictionary in Watch.
1 Like