Project 387: Lemonade Tycoon

16. Create and activate a "buystand" function

Create a local function called something like "buystand" or "buybuilding." Activate it when the button is touched. This function will eventually allow the player to purchase a lemonade stand when they press it.

Starting point file for this challenge

Steps

1. Create a local function called "buystand"

Tell the script you're starting a new local function by just typing "local function" and then the name of your new function, which we'll call "buystand." 

local function buystand

2. Create a parameter called "other"

This parameter will eventually refer to the "other" thing that touches your button (so, like the player jumping on it.) 

local function buystand (other)

3. Hit return to create an "end" to your function

Anything written in between the word "function" and "end" will be the instructions for the buystand function. 

local function buystand (other) end

4. Create a button touched event

Right now, nothing is be activating this function. It needs to be listening for an event to activate. This is similar to a chunk of code in Scratch that has no yellow "when green flag clicked" or "when sprite clicked" block on top - there's no event to wake up the code! 
 
We want it to activate when the button is pressed. Create a button touched event at the end of your code, then connect your "buystand" function to the event. 

button.Touched:connect(buystand)