How can I insert this into a table?

local Data = {}
table.insert(Data, name = value)

I want to insert something like:
Name = name

Something like this:

local Data = {
			Name = v.Name,
			Equipped = v.Equipped.Value,
		}
Data[name] = value
print(Data[name]) --> value

table.insert(Data[name] = value)?

no, just Data[name] = value

1 Like

No, literally just:

Data[name] = value

This sets the name element in Data to be the value.

1 Like

image
???

Data[ability] = value

Thats because you are applying an Instance as the index, just apply the name.

Oops, I didn’t put the name correctly.

Also, what is this?

table.insert(PlayerData, Data)

for _, Data in ipairs(PlayerData) do
			local temp = script:WaitForChild("Template"):Clone()
			print(Data)
			
			temp.Name = Data.Name
			temp.Equipped.Value = Data.Equipped
			temp.EquippedValue.Value = Data.EquippedValue
			temp.Upgrades.Value = Data.Upgrades
			temp.Parent = HeroesFolder
		end

image

(I fixed it.)

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