What is the Difference of Tables and Meta Tables and what can we use them for?

What are the differences from them both?

and also, what is lua and luau and are they the same thing?

Tables are simply used for storing multiple values. -Tables | Roblox Creator Documentation

Metatables are just a way to edit tables into becoming more powerful and have more usage/functionality. - Metatables | Roblox Creator Documentation, here’s a really good post explaining it too: All you need to know about Metatables and Metamethods

Lua is the original coding language, while luau is a roblox edit of lua. Nothing too much to know about it.

1 Like

What are Ipairs() for?

what do people use it for?

pairs() and ipairs() are functions that can be used with a for loop to go through each element of an array or dictionary without needing to set starting or ending points. pairs() is used with dictionaries , and ipairs() is used with arrays . The “i” in ipairs() stands for “index.” - https://education.roblox.com/en-us/resources/pairs-and-ipairs-intro

They are used to loop thru a table/dictionairy that hold multiple stuff, so it’s easier to iterate thru everything inside a dictionairy.

1 Like

Thanks for telling me!


1 Like

So would it be something like this?

for i = ipairs(10) do
   wait(0.5)
   speed.Value = speed.Value + 1
end

if the speed was 0 before this and then they hold down space then each 0.5 seconds the player should have 10 speed at the end right?

Ah, nope, I don’t think that does any function, if you’re trying to loop speed.Value to change:

for 1, 10 do
  speed.Value += 1
  wait(1)
end

This will increase speed’s value every second by 1.

As mentioned before, pairs() and ipairs() are functions that can be used with a for loop to go through each element of an array or dictionary without needing to set starting or ending points.

Say, you have a model and you want to go thru every child of that model you should do:

for i, child in pairs(game.Workspace.Model:GetChildren()) do -- Iterate every child
  child.Transparency = 1 -- Set found child to transparency 1
end

“i” will be the amount of times that it’ll loop, but setting it to just “i” or “_” means we won’t have a end point, it’ll keep looping until no children are found.

1 Like

metatable is just a table ,with events.

local TableWithEvents = {
__index = function()
      print("hello world")
end
}
local EmptyTable = {}
setmetatable(EmptyTable,TableWithEvents)
EmptyTable[1]--picking empty index ,which fires __index function ,in a metatable