#Did i understand right the Returns?

22 messages · Page 1 of 1 (latest)

oak zenith
#

i read more documents and watched more videos about "returns"
What I understand is that you use return when you want to end the coding inside of the function or when you want to get a variable or more variable outside the function
Example:

  local function Test(x,y,z)
  return y -- only taking and using y, x and z are ignored
  end
  local result = Test(1,3,5) -- When i run the game the, in output will only appear 3 because we returned/ selected y

Is this right?

oak zenith
#

Thanks, i was a little confused when i heard returns means that you return a value

forest vortex
#

to make it clear

#

as example

#

I do a code with the if statement

#

"if part.Parent == workspace then
print("true")
end

#

what returns do is

#

it breaks the script

#

exmple:

#

"if Part.Parent == workspace then
print("true")
else
return
end

#

if the parent of the part is something else than the workspace

#

the script will break by using return

sick aspen
normal robin
#

"break" solos

#

whos with me

forest vortex
#

🧑‍🔧

#

me

#

but dont u use that in loops only?

normal robin
#

yeah

#

who cares tho

#

it still solos