How do I use [""]?

So I’m trying to do something like this instead of findfirstchild:

gui.frame[myString].Visible = false

how do I use [“”]

If referring to a table, then [“”] is what you use to find a variable inside a table.

for example:

Table = {
	Bottle = 10,
	Bread = 20,
	Butter = 30,
	Jam = 40,
}

print(Table["Bread"]) -- Prints 20

Assuming “frame” is a Table that you got by using :GetChildren(), then just put the name of the item you wish to hide within the [“”]

frame = GUI:GetChildren()
frame["myString"].Visible = false

Alternatively, [“”] Is commonly used when variables you’re referring to has a space in them.

If you had an object called “Fighting Data” then it would be referred to as workspace[“Fighting Data”] in scripts instead of workspace.Fighting Data.

I don’t think this exactly works as an alternative for FindFirstChild. Do you have any examples saying otherwise?

object['Something'] would do the same as object.Something, the only difference is that you can use special characters and variables.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.