Eclipsin
|
  |
| Joined: 09 Feb 2012 |
| Total Posts: 5197 |
|
|
| 05 Sep 2014 03:38 PM |
i'm a new-ish scripter and the wiki doesn't have that great of an explanation for people like me
-{E_ |
|
|
| Report Abuse |
|
|
|
| 05 Sep 2014 03:47 PM |
| If I'm not mistaken, it will stop running the script and return to the beginning. |
|
|
| Report Abuse |
|
|
|
| 05 Sep 2014 03:48 PM |
you are mistaken. it would be at this point i would give the actual answer, but as im terrible at explaining things. i'll let youtube and the wiki give you it. |
|
|
| Report Abuse |
|
|
|
| 05 Sep 2014 03:49 PM |
froob, return returns a certain object, etc like a parameter example:
function asd(part) return part end
print(asd(workspace.Part)) --would return Part |
|
|
| Report Abuse |
|
|
Vuva
|
  |
| Joined: 22 Jan 2010 |
| Total Posts: 1102 |
|
|
| 05 Sep 2014 04:03 PM |
Yeah it's used with functions
function a() return "Hello World!" end print( a() ) |
|
|
| Report Abuse |
|
|
Tynexx
|
  |
| Joined: 11 Jul 2012 |
| Total Posts: 1559 |
|
|
| 05 Sep 2014 04:06 PM |
function hi(word) return "Hi"..word; end
print(hi("Return"))
Returnes "Hi Return" |
|
|
| Report Abuse |
|
|
|
| 05 Sep 2014 04:06 PM |
Well, first of all he said he was new-ish at scripting, and that would seem fairly complicated to a beginning scripter. I do know that when it's inside a loop like this, then it will return to the beginning of the script and stop running the loop, or at least that's what seems to happen:
for i = 1, math.huge do script.Parent.BrickColor = BrickColor.new("Bright red") wait(1) script.Parent.BrickColor = BrickColor.new("Bright green") wait(1) if script.Parent.Name ~= "Blar" then return end script.Parent.BrickColor = BrickColor.new("Bright blue") wait(1) end
I don't know the definite definition of all of the terms, I just now how I can use them to my advantage. xD
|
|
|
| Report Abuse |
|
|
|
| 05 Sep 2014 04:07 PM |
| That last reply was directed @narb |
|
|
| Report Abuse |
|
|
Tynexx
|
  |
| Joined: 11 Jul 2012 |
| Total Posts: 1559 |
|
|
| 05 Sep 2014 04:08 PM |
function check(player) if player.Name=="Tynexx" then return true else return false end end
check(game.Players.Player1) |
|
|
| Report Abuse |
|
|
|
| 05 Sep 2014 04:13 PM |
It makes it so the function you have 'returns' and argument.
for example:
function sendstring() local string='hello' return string end
-- than when you call it..
local dog=sendstring() local horse=sendstring()
print(dog)--hello print(horse)--hello |
|
|
| Report Abuse |
|
|
Eclipsin
|
  |
| Joined: 09 Feb 2012 |
| Total Posts: 5197 |
|
|
| 05 Sep 2014 04:47 PM |
so it's an alternative to print?
-{E_ |
|
|
| Report Abuse |
|
|
Vuva
|
  |
| Joined: 22 Jan 2010 |
| Total Posts: 1102 |
|
|
| 05 Sep 2014 04:48 PM |
If you don't know about functions, then you should go learn about that first But like other people have said, it can also break a loop, but the keyword "break" can do that aswell. |
|
|
| Report Abuse |
|
|
Vuva
|
  |
| Joined: 22 Jan 2010 |
| Total Posts: 1102 |
|
|
| 05 Sep 2014 04:49 PM |
| By functions, I mean creating them. |
|
|
| Report Abuse |
|
|
Eclipsin
|
  |
| Joined: 09 Feb 2012 |
| Total Posts: 5197 |
|
|
| 05 Sep 2014 04:52 PM |
so it's an alternative to print and break?***
-{E_ |
|
|
| Report Abuse |
|
|
Vuva
|
  |
| Joined: 22 Jan 2010 |
| Total Posts: 1102 |
|
|
| 05 Sep 2014 04:55 PM |
No Everybody is just using print so that you can see for yourself how it works
function a() return 0.5 end Workspace.SomePart.Transparency=a()
That would set the transparency of SomePart to 0.5 |
|
|
| Report Abuse |
|
|
Kardson
|
  |
| Joined: 31 Jul 2014 |
| Total Posts: 62 |
|
|
| 05 Sep 2014 04:56 PM |
| You could watch Peaspod's video on it, he's great at explaining things. Heck, watch all of his tutorials. I am onto his advanced ones and they're really helpful. |
|
|
| Report Abuse |
|
|
anaIyze
|
  |
| Joined: 29 May 2014 |
| Total Posts: 2048 |
|
|
| 05 Sep 2014 05:03 PM |
| 'return' returns any argument in a(n) function, must be defined first. |
|
|
| Report Abuse |
|
|
|
| 05 Sep 2014 05:11 PM |
The way I would explain it is that it (I guess) gives a value to functions.
For instance:
function yomama() return 2 end function givstringmeplz() return "yourstring" end
yonumber = yomama()--This sets yonumber as 2 yostring = givstringmeplz()--This sets yostring to "yourstring" |
|
|
| Report Abuse |
|
|
|
| 05 Sep 2014 05:13 PM |
--As an example,
function Example() return "This is an example string that will be 'returned'" end
print(Example()) --This prints the returned string data to the Output.
Essentially, return ends a function once it's activated and returns data depending on how it was set up.
Using that, you could use something such as,
function A() return 1 end
function B() return 2 end
Sum = A()+B()
print(Sum)
In that example, return essentially just assigned the numbers I specified as the stored value in each function.
--Sum = A()+B() is equivalent to Sum = 1+2
--As a result,
--This would print the number 3.
|
|
|
| Report Abuse |
|
|