Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering Roblox Coding

You're reading from   Mastering Roblox Coding The unofficial guide to leveling up your Roblox scripting skills and building games using Luau programming

Arrow left icon
Product type Paperback
Published in Aug 2022
Publisher Packt
ISBN-13 9781801814041
Length 424 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Mark Kiepe Mark Kiepe
Author Profile Icon Mark Kiepe
Mark Kiepe
Arrow right icon
View More author details
Toc

Table of Contents (16) Chapters Close

Preface 1. Part 1: Start Programming with Roblox
2. Chapter 1: Getting Up to Speed with Roblox and Luau Basics FREE CHAPTER 3. Chapter 2: Writing Better Code 4. Chapter 3: Event-Based Programming 5. Part 2: Programming Advanced Systems
6. Chapter 4: Securing Your Game 7. Chapter 5: Optimizing Your Game 8. Chapter 6: Creating User Interfaces for All Devices 9. Chapter 7: Listening to User Input 10. Chapter 8: Building Data Stores 11. Chapter 9: Monetizing Your Game 12. Part 3: Creating Your Own Simulator Game
13. Chapter 10: Creating Your Own Simulator Game 14. Index 15. Other Books You May Enjoy

Exercise 2.2 – converting loops

In this exercise, we will convert a functioning while loop into a repeat loop. Both loops are very similar. In the Programming loops section, we explained the difference between both. Take a look at the following code snippet:

local spawnLocation = workspace.SpawnLocation
while true do
    spawnLocation.Orientation += Vector3.new(0, 1, 0)
    task.wait()
end

This code snippet rotates SpawnLocation in the Workspace. Feel free to run this script before you convert it.

Exercise:

  • Convert the preceding code snippet into a repeat loop.
  • What is different about the condition of the repeat loop compared to the while loop, and why?

Play the game and make sure the spawn location rotates. If the Output frame displays any errors, try to fix them. An example answer to this exercise can be found on the GitHub page for this book:

https://github.com/PacktPublishing/Mastering-Roblox-Coding/tree/main/Exercises

...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image