xXLuka_XD
|
  |
| Joined: 27 Mar 2016 |
| Total Posts: 296 |
|
| |
|
caca50
|
  |
| Joined: 10 Jul 2011 |
| Total Posts: 2037 |
|
|
| 27 Nov 2016 12:02 PM |
break will break the statement.
return will return a statement.
Roblox.Forum.Scripters:1: bad argument #1 to 'intellect' (number expected, got nil) |
|
|
| Report Abuse |
|
|
| |
|
caca50
|
  |
| Joined: 10 Jul 2011 |
| Total Posts: 2037 |
|
|
| 27 Nov 2016 12:03 PM |
http://wiki.roblox.com/index.php?title=Loops#Break
http://wiki.roblox.com/index.php?title=Function#Using_Return
Roblox.Forum.Scripters:1: bad argument #1 to 'intellect' (number expected, got nil) |
|
|
| Report Abuse |
|
|
xXLuka_XD
|
  |
| Joined: 27 Mar 2016 |
| Total Posts: 296 |
|
|
| 27 Nov 2016 12:05 PM |
| i mean can you explain what return does and break does? I am newbie , so i dont know |
|
|
| Report Abuse |
|
|
caca50
|
  |
| Joined: 10 Jul 2011 |
| Total Posts: 2037 |
|
|
| 27 Nov 2016 12:06 PM |
http://wiki.roblox.com/index.php?title=Loops#Break
http://wiki.roblox.com/index.php?title=Function#Using_Return
^That
Roblox.Forum.Scripters:1: bad argument #1 to 'intellect' (number expected, got nil) |
|
|
| Report Abuse |
|
|
Baheegv2
|
  |
| Joined: 17 Oct 2016 |
| Total Posts: 959 |
|
|
| 27 Nov 2016 12:08 PM |
Imagine that you asked your friend to go and do something everyday for you, which would cost you around 5 bucks
and then 1 day you wanted to stop that procedure, so you would tell him to >STOP< or >BREAK< the act
that's what a break is, you have something that loops and repeats, but you wanna break or stop that loop
as for return, let's say that you were sent 2 packages instead of 1 by mistake, and you'd like to return a message/ or the package itself that you were sent 2 by mistake
That's >RETURNING< info/items in this case
this is exactly what happens in lua, you return information to the caller or the user or the client or w/e you wanna call it, after you have done changes to it or after you have received it yourself
|
|
|
| Report Abuse |
|
|
xXLuka_XD
|
  |
| Joined: 27 Mar 2016 |
| Total Posts: 296 |
|
| |
|
caca50
|
  |
| Joined: 10 Jul 2011 |
| Total Posts: 2037 |
|
|
| 27 Nov 2016 12:20 PM |
local function Add(a,b) return a+b end Add(2,3) -- This is equal to five. It returns the 'a+b'
Here's a bit more complex example:
local function Fact(n) if n==1 then return n else return Fact(n-1)*n end end
print(Fact(4))-- Returns 24 print(Fact(5))-- Returns 120
Roblox.Forum.Scripters:1: bad argument #1 to 'intellect' (number expected, got nil) |
|
|
| Report Abuse |
|
|
Baheegv2
|
  |
| Joined: 17 Oct 2016 |
| Total Posts: 959 |
|
|
| 27 Nov 2016 12:20 PM |
No point in returning if you're not going to refer to the result @caca
|
|
|
| Report Abuse |
|
|
Baheegv2
|
  |
| Joined: 17 Oct 2016 |
| Total Posts: 959 |
|
|
| 27 Nov 2016 12:21 PM |
mb didn't see the bottom part ;v
|
|
|
| Report Abuse |
|
|