Hello, I am making a dictionary that contains the image ID of the name of a tool. However, it is giving me an error when I hover over the red underline. Why is this happening?
3 Likes
You need to add a comma after the first asset ID. For each element in a dictionary, you need to add a comma afterwards.
Your code should look like this:
local imageID = {
["WoodWall"] = "http://www.roblox.com/asset/?id=6695327570", -- comma here
["WoodDoor"] = "rbxassetid://9128090084", -- adding a comma here is optional
-- but i recommend it
}
3 Likes
comma after the first item in your table, this is to divide the table i assume, i never really looked into it, but it is why.
1 Like
local imageID = {
["WoodWall"] = "asset",
["WoodDoor"] = "asset2"
}
To make this 100% clear, if you were planning to add more values, you’d need commas next to all of them too, like this. Every single thing gets a comma after it, besides the final one.
local imageID = {
["WoodWall"] = "asset",
["WoodWall2"] = "asset",
["WoodWall3"] = "asset",
["WoodDoor"] = "asset2"
}
Lua additionally allows you to use a semi-colon instead of a comma to delimit items/elements within a table.
local array = {1; 2; 3;}
local dictionary = {
["a"] = true;
["b"] = true;
["c"] = true;
}
1 Like