How can you print from the table i want to print 5 from the tables but it won't print.
local Game = {5,10,20}
for i,v in pairs(Game) do
Game[i] = v+5
print(v[1])
end
How can you print from the table i want to print 5 from the tables but it won't print.
local Game = {5,10,20}
for i,v in pairs(Game) do
Game[i] = v+5
print(v[1])
end
There are a bunch of things wrong with your script:
Firstly, avoid using table names similar to services or in this case the actual game object. Secondly you don't have to loop through the table in order to print what you want, you can do it as easily as this
local Table = {5,10,20} --changed the table name so that it doesn't get mixed up with the actual game object
print(Table[1]) --you select the first index inside of the Table array and print it
If this helped you solve your problem please mark it as the answer!
my answer better
XD
There is a difference between a dictionary and an array in tables, a dictionary can have specific values called upon but in an array you must know where that is located.
Here is an example of an array:
local Game = {1,2,3}
And here is an example of a dictionary:
local Game ={
["a"] = 1,
["b"] = 2,
["c"] = 3
}
To call upon a specific place in a dictionary, simply use:
game["c"] -- // example
TL;DR: use this:
local Game = {
[1] = 5,
[2] = 10,
[3] = 20
}
for i,v in pairs(Game) do
print(Game[i])
end
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
What are you casually trying to do?