Can you explain 'returning' to me simply?

Hello. I’m Alex, I’ve tried since I started to code to learn ‘returning’, but I never understood it.
Each time I try to understand it, it looks useless to me and I know it’s very useful, but I still can’t understand. I know this subject has been answered multiple times, but all the answers were ticked as solutions did not help me so far, and I’m looking for an explanation that will help me understand it.
I know returning is a subject for starters, but when I was a starter I did not understand it too; and now I do not still. It would be much appreciated to at least try to help me understand it.

Thank you,
XDvvvDX.

I answered this before.

Could you explain what you didn’t understand out of other topics?

3 Likes

returning something from a function just gives whatever called it, whatever you return.

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

local result = Add(1,2);
print(result) -- 3

It can also be used to interrupt/stop a function if you don’t want it to continue, by just returning nothing.

1 Like

Hello. Thank you for replying to me, it is much appreciated.
I did not understand the purpose of returning. I do understand functions well, but for some reason
returning is ‘hard’ for me to understand. Could you explain it’s purpose to me?

Thanks,
XDvvvDX.

Please read the linked reply, it is explained there. Also no need to sign all your posts.

I’ve done reading it. It was really helpful.
Thank you for spending your time helping me, it was much appreciated.

Thanks,
XDvvvDX.

Thank you for replying to me, your comment was helpful too, but I first saw his comment so
I can’t tick 2 answers as solutions. Thank you still for wanting to help me, it is appreciated.

Thank you,
XDvvvDX.