#Return

1 messages · Page 1 of 1 (latest)

hidden hedge
#

local function Adding(n1, n2)
local add = n1 + n2
return add
end

#

Hi im a scripter in roblox i have a few question of how to use return in roblox, but i dont understanding how to use it and when to use it, if someone could help me i will be very grateful

lofty lynx
#

jk

#

try messing with it like you usually do with other stuff like functions

#

try putting it in different situations

#

and read about it

untold summit
# hidden hedge Hi im a scripter in roblox i have a few question of how to use return in roblox,...

To explain it simply, "return" give the value back to the line it was called, for example your function

local function Adding(n1, n2)
  local add = n1 + n2
  return add
end

now, when you use the return it sends the value of add, and to where? let's say you make a variable,

local function Adding(n1, n2)
  local add = n1 + n2
  return add
end

local calculatorAdd = Adding(1, 5)

the value of calculatorAdd would be..

6

does this explanation make sense?
you can use return in many other ways, but to explain it in a nutshell, if gives back the value you "returned" to the line it was called.

hidden hedge
#

i've heard return is used to escape or stop a fuction

oak stirrup
untold summit