![]() ![]() You want them to have collisions based on a given number’s parity. Now suppose you have a few parts in your game. Returning gives something back to you from a function call. I hope you understand this because from here we will see how return can fit this analogy. Just like how a variable is a container of arbitrary data, you can think of a function that is a “variable that holds code” that you can reuse when necessary. The second one is much easier to read as well as edit. local function edit_color(brick_color)Įdit_color(BrickColor.new("Bright green"))Įdit_color(BrickColor.new("Bright blue")) Look at all that unnecessary copy-pasting! Using a function we can shorten (as well as simplify) this script. Parts.BrickColor = BrickColor.new("Bright green") Parts.BrickColor = BrickColor.new("Bright blue") For instance say I have this code that changes the color of 3 parts to green then to blue. The purpose of a function is to shorten and simplify your code. Before you understand return you need to understand a function’s purpose.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |