Ahkaiken
|
  |
| Joined: 14 Jan 2013 |
| Total Posts: 65 |
|
|
| 15 Feb 2014 10:01 PM |
| Can someone explain what return does? The wiki didn't make much sense. |
|
|
| Report Abuse |
|
|
Ahkaiken
|
  |
| Joined: 14 Jan 2013 |
| Total Posts: 65 |
|
| |
|
CrniOrao
|
  |
| Joined: 12 Oct 2008 |
| Total Posts: 2274 |
|
|
| 16 Feb 2014 10:00 AM |
It can be used in an if for example.
if (condition) then --something else return --returns it back. end |
|
|
| Report Abuse |
|
|
MrNicNac
|
  |
| Joined: 29 Aug 2008 |
| Total Posts: 26567 |
|
|
| 16 Feb 2014 10:12 AM |
It makes a function call equal other values, basically. What does this mean? Do you know what a function call is?
It looks like this:
FunctionName()
So, what if I made a function named "X" and returned 2
function X() return 2 end
What do you think print( X() ) would put in the output?
> 2
Because when you run the function X, it returns 2. So the part where you put X() is now 2 instead of X() |
|
|
| Report Abuse |
|
|
Kingmouli
|
  |
| Joined: 28 Sep 2012 |
| Total Posts: 1292 |
|
|
| 16 Feb 2014 10:15 AM |
An exemple would be in a gun script
function makebullet() b = Instance.new("Part") --thingys return b end
Now in another part of the script
bullet = makebullet()
The variable bullet is assigned to what makebullet() returns |
|
|
| Report Abuse |
|
|