For an example can I do:
1 | local hat = hit.Parent:FindFirstChild( "Noob" , "Pro" , "Bob" ) |
Or is this not possible? All help is appreciated!
I don't think it is possible, you'll need to use a table instead (http://wiki.roblox.com/?title=Table).
You need to use a table, you will need this code:
1 | hat = { "Noob" , "Pro" , "Bob" } |
Then you need to use for i,v in pairs
stuff, pls refer to tables in the wiki.
Click here to go to the wiki post about tables.
No.
Imagine I had something like
1 | friend = (Alice, Bob, Eve) |
How could I answer questions about friend
?
What is friend.Name
? Answering just "Alice"
or just "Bob"
is wrong. Should we answer all three? In what order? What does, e.g., friend.Name:sub(#friend.Name)
(the last letter of their name) mean? Is it ("e", "b", "e")
? Or are the two friend
s different, meaning it's ("e", "i", "i", "", "b", "b", "", "e", "e")
? Do we discard duplicates?
Is friend == Alice
true
, false
? Or is it perhaps (true, false, false)
?
If I insert friend
into a list,
1 | local list = { } |
2 | table.insert(list, friend) |
How big is list
afterwards? Does it contain 3 things, or 1? Is there an order of those things?
A value is a single object, but that object may be a collection of other values.
For example, a list or set of values can be represented as a table:
1 | friends = { Alice, Bob, Eve } |
We can now provide meaningful answers to these questions.
friends
doesn't have a name, but each friend has a name:
1 | for _, friend in pairs (friends) do |
2 | print (friend.Name) --> Alice, Bob, Eve |
3 | end |
friends == Alice
is of course false, but we could write a function that lets us ask contains(friends, Alice)
-- is Alice
included in our list of friends
?
Adding friends
to a list just adds one thing -- this group of friends. But we can explicitly add each one individually, too:
1 | for _, friend in pairs (friends) do |
2 | table.insert(list, friend) |
3 | end |