# Luau入門5:テーブル(配列と辞書) > Luauのテーブルは、たくさんの値をまとめるための入れ物です。番号で取り出す「配列」と、名前で取り出す「辞書」の2つの使い方があります。 - URL:https://roblox.minecraft-okinawa.com/luau/tables/ - 更新日:2026-11-13 ## 配列(番号で並べる) ```lua local fruits = { "りんご", "バナナ", "みかん" } print(fruits[1]) table.insert(fruits, "ぶどう") print(#fruits) for index, fruit in ipairs(fruits) do print(index, fruit) end ``` - 配列の番号は1から始まります。 - 「#配列」で、中に入っている数が分かります。 - table.insert で、最後に追加できます。 - ipairs で、番号の順に1つずつ取り出せます。 ## 辞書(名前で取り出す) ```lua local profile = { name = "Alex", level = 5 } print(profile.name) profile.level += 1 for key, value in pairs(profile) do print(key, value) end ``` 辞書では、「名前 = 値」の組を入れておき、profile.name のように名前で取り出します。pairs で、すべての組を取り出せます。 ## 出典 - [Luau 公式サイト](https://luau.org/) - [Roblox Creator Documentation](https://create.roblox.com/docs) 執筆:鈴木孝昌(現役プロジェクトマネージャー/プログラミング講師)/運営:沖縄マイクラ部 プログラミングスクール「クロスウェーブ」(https://minecraft-okinawa.com/)