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

Return

Asked by 11 years ago

Well, can someone explain to me what the return function in scripts do? Please? :]

1 answer

Log in to vote
9
Answered by
User#2 0
11 years ago

SH Glossary

ROBLOX Wiki

Lua Pil

I'd say return is, simply put, the function is giving some thing(s) back. The provided links, though, go more in-depth if you would like.

Example:

01function FunctionThatReturns(x) -- Define our function and give it a parameter
02    print(x) -- Print "x" to the output
03    return x + 1 -- Give back x + 1
04end
05function FunctionThatDoesntReturn(x) -- Define our other function, also with a parameter
06    print(x) -- Output "x"
07end
08 
09print(FunctionThatReturns(5)) --> The function will print "5" then this will print "6"
10print(FunctionThatDoesntReturn(11)) --> The function will print "11" then this will print nothing, as nothing was given back.
Ad

Answer this question