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
 

Re: Need Clarfication

Previous Thread :: Next Thread 
foxmaster600 is not online. foxmaster600
Joined: 14 Oct 2009
Total Posts: 147
25 Nov 2015 05:01 PM
Right now, I'm learning how to script, I'm sure you've might have seen me around the Scripting forum a few times by now, asking questions, so, here's another one I have:

Currently studying Data Persistence / DataStores. And the part I'm at in the tutorial is... well, the dead beginning, because...

-------------------

local HPacks = {}
local sessionData = {}
function HPacks:ChangeStat(player, statName, changeValue)
sessionData[player][statName] = sessionData[player][statName] + changeValue
end
local function setupPlayerData(player)
sessionData[player] = {Money = 0, Experience = 0}
end
game.Players.PlayerAdded:connect(setupPlayerData)
return HPacks

--------------------

I'm confused what a "return" does. My basic idea is that it... gets the value of whatever is typed after it?

Just reply with what it does, please...
Report Abuse
Ristone3 is not online. Ristone3
Joined: 17 Aug 2008
Total Posts: 693
25 Nov 2015 05:38 PM
This might help you

function Thing(message)
print(message)
return true
end

if Thing("Hello") == true then
print("It printed successfully!")
else
print("Something went wrong")
end

Output:
Hello
It printed successfully!



So basically, it's a way to get a message from a function, it basically sends information back. What it sends back can be a bool, a number, a string, a table, or even an object.
Report Abuse
foxmaster600 is not online. foxmaster600
Joined: 14 Oct 2009
Total Posts: 147
25 Nov 2015 07:30 PM
Still seems confusing, when you called the function in the conditional statement, "Hello" became the "message"?

-I was about to say something, but I see that the function was called in in the condition... which... Ugh, my head can't take this right now...

Explain... Explain! EXPLAIN!
Report Abuse
foxmaster600 is not online. foxmaster600
Joined: 14 Oct 2009
Total Posts: 147
30 Nov 2015 09:48 AM
Buuuuuuuump.

That last post was me at a bad time. Also, Doctor Who reference.
Report Abuse
OzzyFin is not online. OzzyFin
Joined: 07 Jun 2011
Total Posts: 3600
30 Nov 2015 10:02 AM
if you don't yet understand how functions are used, you shouldn't go to datastores yet


function a(argument)
print(argument)
end

a("hello") -- calling function a with "hello" being the argument
a("hi") -- calling function a with "hi" being the argument
a("bye")

this wiki page should explain it quite well
http://wiki.roblox.com/index.php/Arguments_and_parameters

I personally still don't understand the difference between terms argument and parameter, because the wiki is kinda mixing them up, however it shouldn't matter.

return is simply explained here:
http://wiki.roblox.com/index.php?title=Function#Using_Return

Report Abuse
OzzyFin is not online. OzzyFin
Joined: 07 Jun 2011
Total Posts: 3600
30 Nov 2015 10:05 AM
@"I personally still don't understand the difference between terms argument and parameter, because the wiki is kinda mixing them up"

what I mean with this is, in wiki there's a line

function name(argument1, arg2, arg3...) --arguments are only inserted when needed

and another

function PrintStuff(x) --this is a function, and it has one parameter, 'x'.
PrintStuff("Hello world.") --"Hello world." is the argument

I've always thought that when calling a function you call it with 'parameters' and a function turns those parameters into 'arguments'

again who cares
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
30 Nov 2015 12:19 PM
The difference between arguments and parameters is largely semantic; when defining the function, you supply parameters. When calling the function, you supply arguments (which take the place of the parameters).
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