I have seen all kinds of brackets these : {} I think are for tables these () I think are for parameters . BUT THESE [] I cannot understand. I don’t get what [] bracket do.
A lot of times it's used to get certain stuff out of tables or dictionary's, but it can also be used to find a child inside of Workspace or another place, It can find children with spaces
Dictionary example: (Tables and Dictionary's are almost the same}
-- Make the dictionary using the [] brackets to name them! local fruitDictionary = { ["Bananas"] = "Not my favorite"; ["Apples"] = "Pretty good"; ["Eggplants"] = "Sus"; } -- Print the Eggplants print(fruitDictionary ["Eggplants"]) -- When you run the script it should say sus!
Children Example
workspace["My Part that has a space"].BrickColor = BrickColor.new("Bright green")
Hope this answered your question!
Square brackets are used to reference items in a table. For example:
local table = {12, 41, 62} print(table[2]) --prints 41 table[2] = 123 print(table[2]) --prints 123 print(table[1]) --prints 12
They can also be used to reference table keys that are strings:
local table = { ["oranges"] = 152, ["apples"] = 127, ["potatoes"] = 4 } print(table["apples"]) --prints 127
Square brackets can be used to find things you may not be able to without using them. another use is for picking a certain item in a table
part = workspace.my part -- This will not work part = workspace["my part"] -- this will work mytable = {one, two, three} mytable[2] = "seven"
I hope this makes sense
hey you! have you ever heard of enes? if you are in trouble, better call enes!