Getting a table name

How do I get a table’s name? Not much to say.
print(v) prints the literal table
print(i) prints 1

1 Like

printing can’t output that kind of error

1 Like


Something tells me it can.

1 Like

well line 75 isn’t where u do print(v) is it

1 Like

Oh. Right, let me fix that. (char limit)

1 Like

Could you show where you save cDataStore? It matters what type of data you’re storing.

1 Like
	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)
1 Like

aren’t you supposed to do

plr.c[tablename].Value = v[1]
1 Like

c isnt a table. tablename is 1. (i forgot to tell you that i changed it from 1 to tablename

1 Like

well eitherway v is a table and you can’t index c with a table

1 Like

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

1 Like

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
1 Like

so then how do i get the key??

1 Like

the same way you set it

local value = cData["Example"]

and that will return 1

1 Like

i cant do that because then there would be
cData[“Hungry”]
cData[“Armed”]
cData[“Transparent”]
cData[“Fiery”]
cData[“Confused”]
ect

1 Like

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

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.