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

What is a function i can use to break out of a function?

Asked by 4 years ago

How does one break out of a touch function?

0
Try 'return' Hypgnosis 186 — 4y
0
Make this an answer so i can verify it User_3805 6 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago

to discontinue execution of a function you need to use the return keyword:

for instance:

function sayHello(who)
    if(not who) then
        print"you did not specify a person to say hello to."
        return --terminates further execution!
    end

    print("Hello, ",who,".  how are you?")
end

sayHello("Roblox") --//"Hello, Roblox. How are you"
sayHello()--//"you did not specify a person to say hello to."
Ad

Answer this question