piece=Workspace.Part
Hello={piece,"What?",true,76}
print (Hello[3])
Output =true
Could I call the argument by their name for example
Hello["What"]
piece=Workspace.Part
Hello={piece,"What?",true,76}
print (Hello[3])
Could I call the argument by their name for example
Hello["What"]
No, it returns nil if you do that.
It's not needed though, as if you know the name of it, the easiest solution is to do something like this-
Hello = {piece,"What?",true,76}
for a,b in pairs(Hello) do
if b == "What" then
-- b is "What" in your table, code it as you wish
print(b.. " has been found")
end
end
What this does, basically, is will check each value of the table (as a generic for loop would), only giving any physical output when it gets to "What?".
Good luck, I tried to help! Please consider leaving an upvote!
"What" is not a key in the table Hello.
I don't know what it is that you are asking.
object = {};
object["hi"] = 15;
print(object["hi"]); -- 15
print(object.hi); -- 15
other = {["hi"]=9};
print(other.hi); -- 9
some = {hi=2};
print(some.hi); -- 2
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
Nice technique forgot I could do that.
Thanks!