Sign in
Home
Online Classes
Instructors
Tutorials
☰
Register
Sign in
Online Classes
Instructors
Tutorials
1. Open Roblox Studio and Setup a New Project
2. Set Up Coin
3. Add a Script to ServerScriptService
4. Make CreateCoin Function
5. Closer Look at CreateCoin( ) (c)
6. Add a loop to create multiple coins
7. Test Out Your Code
8. Update CreateCoin( )
9. Test Out Your Code
10. Make the Coins 'Collectable'
11. Test Out Your Game
12. Add Sound Effect (Optional)
Project 369: Collecting Coins
6. Add a loop to create multiple coins
Create a loop to create some number of coins. In our case we’re creating 40 coins.
Starting point file for this challenge
Hint: show steps
Steps
1. Create local variable 'totalCoins'
Hint: show details
Outside of the function, create a local variable called `totalCoins` to keep track of how many coins we’ve created. This needs to be created outside the loop so it doesn’t reset every time the loop runs. Start this number at 0.
local totalCoins = 0
Hint: show image
Hint: show code
2. Make a while loop
Hint: show details
Create a while loop that keeps running as long as 'totalCoins' is less than 40.
while totalCoins < 40 do end
Hint: show image
Hint: show code
3. Create a coin
Hint: show details
Make it so that each iteration of the loop runs the 'CreateCoin( )' function.
CreateCoin()
Hint: show image
Hint: show code
4. Add 1 to 'totalCoins'
Hint: show details
Make it so that each iteration of the loop adds 1 to the 'totalCoins' variable.
totalCoins = totalCoins + 1
Hint: show image
Hint: show code
5. If you wanted to create 60 coins, what would you need to change?
Hint: show details
Don't actually change your code, but make sure you tell your instructor what you think the answer is before moving on.
×
×
Provide your email address for immediate project access
Email
Check your email for instructions on how to create a full DA account