This is what i am trying to achieve:
This is table before:
local Table = {}
And i want to add value to it like this:
local Table = {["Basic Color"] = Color3.new(0,0,0)}
Yeah that is pretty much it.
This is what i am trying to achieve:
This is table before:
local Table = {}
And i want to add value to it like this:
local Table = {["Basic Color"] = Color3.new(0,0,0)}
Yeah that is pretty much it.
table.insert(Table, ["Basic Color"] = Color3.new(0,0,0))
local Table = {}
Table["Basic Color"] = Color3.new(0,0,0) -- yay
print(Table)
@kelvinsverdlov1 that is not valid syntax
My bad, I’ll note that. Haven’t used lua in a while.
I was curious (sometimes Lua supports weird syntax no one uses), looks like this isn’t valid syntax.
lua: main.lua:3: unexpected symbol near '['
["Basic Color"] = Color3.new(0,0,0)
doesn’t become an object, so this isn’t possible.
Insert parameter descriptions:
tableVal
: This is the table structure in which the valuenewValue
is to be inserted.index
: This is a numeric value that specifies the position intableVal
in which the valuenewValue
is to be inserted. This is an optional parameter.newValue
: This is the value that we want to insert intableVal
.
Source: Educative Answers - Trusted Answers to Developer Questions
So you can’t replace the insert index with a string either–it has to be numerical.
RickAstll3y has the correct way to set an index in the dictionary portion of the table.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.