Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

How do you return and use more than 1 thing?

Asked by 6 years ago
Edited 6 years ago
1function GetStrings()
2    local String1 = "Hi my name is"
3    local String2 = "iLordOfAviation"
4 
5    return String1, String2
6end
7 
8local Strings = GetStrings()
9print(Strings[1], Strings[2])

I expected this to print "Hi my name is iLordOfAviation" but it didn't... How do you do this?

2 answers

Log in to vote
0
Answered by
Amiaa16 3227 Moderation Voter Community Moderator
6 years ago
1function GetStrings()
2    local String1 = "Hi my name is"
3    local String2 = "iLordOfAviation"
4 
5    return String1, String2
6end
7 
8local String1, String2 = GetStrings()
9print(String1, String2)

Simple, isn't it? :)

0
thanks User#1007 6 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

Try this

1local GetStrings = {
2    String1 = "Hi my name is",
3    String2 = "iLordOfAviation"
4}
5local Strings = GetStrings
6 
7print(Strings.String1)
8print(Strings.String2)
0
whoops wrong code xd xJathur95x 129 — 6y
0
Maybe try Kiriot22's code.. xJathur95x 129 — 6y

Answer this question