Whenever I use the In Pairs, I couldn't Understand the index, and the value, Like for example, I have a Box with a Car in it, would the Box(outside) be the index, and the value would be the Car INSIDE the Box?
Please Respect that I am a Scripter in need for Knowledge
It's kind of hard to explain, but:
Table = { Index = Value }
Index and value could be anything.
If an index isn't assigned but a value is, the index will be the length of the table + 1. For example:
Table = {} table.insert(Table, "hello")
"hello"
will have an index of 1 because the table is empty.
Index is the Interval, and Value is the value of the table. i and v are just variables for index and value. You can change them to whatever you'd like. Here's how pairs would look in a while loop:
local tab = {"one","two","three","four","five"} local i = 0 while i < #tab do i = i + 1 v = tab[i] end
Here's an example of how the variables can be changed:
local admins = {"Player","Player1","aquathorn321","TheContinentofEurope"} local admin == "aquathorn321" for number, player in pairs(admins) do if player == admin then print(admin.." Is an admin!") end end