table lua
local Table = {
["TABLE_info"] = "TABLE_response"
}
for i, v in pairs(Table) do
print(v)
end
4.22
9
--You need to use this {} and put them in a varible
local Table = {13,"1hihihi",
-- u can even do tis
{122,222}}
Thank you!
9
0
4.44
9
local favoritefoods_table = {"hamburger", "spaghetti", "pizza", "potato chips"}
--the table--
for i, v in pairs(favoritefoods_table) do --loop through the table--
print(i) --print the number--
print(v) --print the value--
end
Thank you!
9
0
3.86
7
a = {}
x = "y"
a[x] = 10 -- put 10 in field "y"
print(a[x]) --> 10 -- value of field "y"
print(a.x) --> nil -- value of field "x" (undefined)
print(a.y) --> 10 -- value of field "y"
Thank you!
7
0
3.57
7
for k,v in pairs(table) do
table.remove(table, k)
end
Thank you!
7
0
4
1
local Table = {
"Hello",
"Goobye",
"Bruh",
Part = Instance.new("Part")
}
-- This is our table!
print(#Table)
--[[
This will print the amount of stuff inside the table by numbers!
For example, if you had 140 objects inside a table (doesn't matter if it's a
string) then print(#Table) will print out the number 140, exactly how many
things are inside the table!
Output: (the amount of objects inside the table BY NUMBERS)
]]
for i, v in pairs(Table) do
print(i,v)
end
--[[
This is a for loop. It will go through each and every object inside the table.
i is the index. The index is like the line number, where the object is located.
Let's say that Bob is the 4th object in the table.
If we would think of tables as lines, Bob would be at line 4.
So if we'll do print(i) it would print out the line where Bob is.
Output: 4
As long as you use a for loop to get every object!
v is the object itself.
Let's say yet again that Mark is inside the table.
so v would be counted as Mark himself.
if we would do print(v) it will print out the name,string etc. of the object!
Output: Mark
]]
Thank you!
1
0
Are there any code examples left?
New code examples in category Lua
-
Lua 2022-03-27 16:30:01 how to use for iv in pairs
-
Lua 2022-03-27 15:10:08 lua last item in table
-
Lua 2022-03-27 07:10:05 how to make a table in lua
-
Lua 2022-03-25 05:45:17 function parameters roblox
-
Lua 2022-03-24 19:50:37 lua variables
-
Lua 2022-03-16 23:30:02 lua list of all keys
-
Lua 2022-03-16 21:40:31 play sound love2d
-
Lua 2022-03-12 11:15:06 how to get the player mouse in roblox studio
-
Lua 2022-03-12 09:40:17 how to add a damage decimal in roblox studio
-
Lua 2022-03-02 18:40:19 lowercase lua