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

Return

Asked by 10 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
10 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:

function FunctionThatReturns(x) -- Define our function and give it a parameter
    print(x) -- Print "x" to the output
    return x + 1 -- Give back x + 1
end
function FunctionThatDoesntReturn(x) -- Define our other function, also with a parameter
    print(x) -- Output "x"
end

print(FunctionThatReturns(5)) --> The function will print "5" then this will print "6"
print(FunctionThatDoesntReturn(11)) --> The function will print "11" then this will print nothing, as nothing was given back.
Ad

Answer this question