Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Calling table arguements!?

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"]

2 answers

✓ Accepted answer

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!

2 comments

0

Nice technique forgot I could do that.

0

Thanks!

"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.