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 » Scripters
Home Search
 

[ Content Deleted ]

Previous Thread :: Next Thread 
WAATERMELON is not online. WAATERMELON
Joined: 03 Jul 2014
Total Posts: 921
04 Dec 2014 03:44 PM
[ Content Deleted ]
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
04 Dec 2014 03:48 PM
It returns a value.
(Oops, I broke the rule)

Don't use functions for this, but here is an example.

function Example()
return 5
end

print(Example())
->5

Here's another example, this one is better to use than the previous.

function Example2(Num1, Num2)
return Num1 + Num2
end

print(Example2(5, 7))
->12
Report Abuse
WAATERMELON is not online. WAATERMELON
Joined: 03 Jul 2014
Total Posts: 921
04 Dec 2014 03:50 PM
[ Content Deleted ]
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
04 Dec 2014 03:52 PM
It gives a function value.
Report Abuse
WAATERMELON is not online. WAATERMELON
Joined: 03 Jul 2014
Total Posts: 921
04 Dec 2014 03:54 PM
[ Content Deleted ]
Report Abuse
C0D3Y is not online. C0D3Y
Joined: 24 Jul 2010
Total Posts: 1692
04 Dec 2014 03:54 PM
The most common examples I've seen are when you set a variable equivalent to the function. Example:

function Add(num1,num2)
return num1 + num2
end

sum = Add(2,5)

print(sum)


Or something like that. Depending on your style, you can probably get away with never using it. It's mostly used when you're using the function repeatedly with different outcomes, but you want the same effect. I'm probably doing a poor job explaining it, but hopefully you get the gist of it.
Report Abuse
WAATERMELON is not online. WAATERMELON
Joined: 03 Jul 2014
Total Posts: 921
04 Dec 2014 03:56 PM
[ Content Deleted ]
Report Abuse
joelsdarkside22 is not online. joelsdarkside22
Joined: 18 Mar 2009
Total Posts: 1131
04 Dec 2014 03:56 PM
it turnres something

eg;

local add=function(a,b)
return a+b
end

print(add(1,1))
--> 2
Report Abuse
WishNite is not online. WishNite
Joined: 11 Feb 2009
Total Posts: 15828
04 Dec 2014 04:01 PM
note: this is inefficient as you can be using table functions like table.sort

table = {7,5,3,2,6}
function findhighestvalue()
local highest = 0
for _,number in ipairs(table) do
if number > highest then highest = number end
end
return highest
end

print(findhighestvalue())
>7
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
04 Dec 2014 04:05 PM
I already gave you two examples that should explain it entirely.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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