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
 

Re: What does return do?

Previous Thread :: Next Thread 
Ahkaiken is not online. 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 is not online. Ahkaiken
Joined: 14 Jan 2013
Total Posts: 65
16 Feb 2014 09:35 AM
Bump
Report Abuse
CrniOrao is not online. 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 is not online. 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 is not online. 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
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