generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

what is "return"'s actual purpose

Previous Thread :: Next Thread 
Eclipsin is not online. 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
MultiRealm is not online. MultiRealm
Joined: 12 Mar 2014
Total Posts: 94
05 Sep 2014 03:47 PM
If I'm not mistaken, it will stop running the script and return to the beginning.
Report Abuse
VerifiedName is not online. VerifiedName
Joined: 26 Jul 2009
Total Posts: 4534
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
narbfaic2014 is not online. narbfaic2014
Joined: 31 Mar 2014
Total Posts: 384
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 is not online. 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 is not online. 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
MultiRealm is not online. MultiRealm
Joined: 12 Mar 2014
Total Posts: 94
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
MultiRealm is not online. MultiRealm
Joined: 12 Mar 2014
Total Posts: 94
05 Sep 2014 04:07 PM
That last reply was directed @narb
Report Abuse
Tynexx is not online. 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
LordMatthewII is not online. LordMatthewII
Joined: 20 Aug 2011
Total Posts: 10873
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 is not online. 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 is not online. 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 is not online. Vuva
Joined: 22 Jan 2010
Total Posts: 1102
05 Sep 2014 04:49 PM
By functions, I mean creating them.
Report Abuse
Eclipsin is not online. 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 is not online. 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 is not online. 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 is not online. 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
ScrewDeath is not online. ScrewDeath
Joined: 03 Jun 2012
Total Posts: 2700
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
AnonyAnonymous is not online. AnonyAnonymous
Joined: 23 Jun 2013
Total Posts: 6332
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image