Project 387: Lemonade Tycoon

18. Check to see if the player is allowed to buy the stand

First, make sure the lemonade stand hasn't already been bought. Then, check to see if the player has a enough money to afford buying the stand.

Starting point file for this challenge

Steps

1. Create an if-statement checking if purchased is false

You only want to let the player buy the stand if it hasn't already been bought. (If purchased is true, then we wouldn't want to let the player buy the stand again.)

You need two equal signs to ask if something is equal or not. 

Remember to hit return on your keyboard to create an "end" to your if-statement. 

if purchased == false then end

2. Create an if-statement checking if the player has enough money

You'll be checking if the value of the player's coins are greater than or equal to the cost of the lemonade stand. 

Remember to hit return on your keyboard to create an "end" to your if-statement. 

if coins.Value >= cost then end

3. Access the coins variable

We actually have to be more specific about this coins variable. The coins variable was actually initialized in a different script, and Roblox needs help looking for it in that other script. 

The coins are hiding in the leaderstats, which is hiding in the player. 

if player.leaderstats.coins.Value >= cost then

4. Create a local "player" variable

Okay, we unfortunately can't just write "player" - Roblox doesn't understand exactly what we mean by that. We have to tell it what player means. 
 
Create a new local variable called "player." Create this variable right above the if-statement that checks about a player's coins. 

local player =

5. Define the "player" variable

You're going to set the "player" variable to long line of code. This line of code is asking Roblox to grab a player object from the character variable. 
 
(Character is the parent of the "other" thing that ran into your lemon.) 

local player = game.Players:GetPlayerFromCharacter(character)