How do I get a table’s name? Not much to say.
print(v) prints the literal table
print(i) prints 1
printing can’t output that kind of error
well line 75 isn’t where u do print(v) is it
Oh. Right, let me fix that. (char limit)
Could you show where you save cDataStore? It matters what type of data you’re storing.
local plrChecklist = {}
local checklist = player.c:GetChildren()
for i, v in pairs(checklist) do
checkListItem = v.Name
checkListItem = {
v.Value
}
table.insert(plrChecklist, checkListItem)
end
local success, errormessage = pcall(function()
cDataStore:SetAsync(playerUserId, plrChecklist)
end)
aren’t you supposed to do
plr.c[tablename].Value = v[1]
c isnt a table. tablename is 1. (i forgot to tell you that i changed it from 1 to tablename
well eitherway v is a table and you can’t index c
with a table
then how do i get the tables name? i know its possible. also, could i change the key or something because the key is 1 thats why im saying its 1
there is no table’s name. the table is represented by keys and values so if you want to have a “name” you should set it as the key when you’re saving the datastore
something like
cData["Example"] = 1
so then how do i get the key??
the same way you set it
local value = cData["Example"]
and that will return 1
i cant do that because then there would be
cData[“Hungry”]
cData[“Armed”]
cData[“Transparent”]
cData[“Fiery”]
cData[“Confused”]
ect
you can do
for tablename , v in pairs(cData) do
plr.c[tablename].Value = v
end
tablename will be Hungry
for example and v
will be the value in that key
thank you so much! the saving and loading worked well too
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.