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
function GetStrings()
    local String1 = "Hi my name is"
    local String2 = "iLordOfAviation"

    return String1, String2
end

local Strings = GetStrings()
print(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
function GetStrings()
    local String1 = "Hi my name is"
    local String2 = "iLordOfAviation"

    return String1, String2
end

local String1, String2 = GetStrings()
print(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

local GetStrings = {
    String1 = "Hi my name is",
    String2 = "iLordOfAviation"
}
local Strings = GetStrings

print(Strings.String1)
print(Strings.String2)
0
whoops wrong code xd xJathur95x 129 — 6y
0
Maybe try Kiriot22's code.. xJathur95x 129 — 6y

Answer this question