Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to use Returns?

Can someone explain returns to me plz? The wiki makes no sense to me.

1 answer

✓ Accepted answer

Returning is a way to get info out of a function. Let me give you an example:

function Add(a,b)
    return a+b
end

This will take two numbers and add them together, then return the result.

So if we do this:

Add(1,3)

Lua will read it as '4'

Here's a full example:

function Add(a,b)
    return a+b
end

print(Add(2,5)) --this will print 7

You can also return booleans and strings. Returning is useful for functions that 'check' whether something is true, or return a string based on user input.

1 comment

0

"return" replaces where the function was called with whatever you put after the return statement.

This discussion is preserved as it was. New answers, comments, and votes are closed.