#Is it possible to call a child using a string variable?
15 messages · Page 1 of 1 (latest)
There are two ways to index something, the first is just using the . to access any propertys or children, and brackets to do the same thing
script.Parent[var].Visible = true
Or script.Parent["Y"].Visible = true
Appreciate it, thanks.
Same applies to tables
local tbl = {["Silly Do Dad"] = 5}
print(tbl["Silly Do Dad"] -- -> Output: 5
Could also use script.parent:FindFirstChild(var) but generally just do as snicka says
@nimble crater using indexing like that also searches through the objects properties
So in the rare case that you're looking for a child with a property name it'll get weird
This method does a function call which is fine but slightly slower
Yea thats why i said he should just do what u said
Really? Thats cool. That can be useful, i didnt know that.