Stage 1: Ascending Walls
Prerequisites: Before You Dive In!
Before diving into the excitement of Stage 1, make sure you've completed these fun and essential steps!
1. Intro
Did you enjoy the grand introduction to Roblox Entrepreneur Part 1: Lua Coding and Game Scripting? We hope you're pumped up and ready to embark on this coding adventure!
2. Setup
Time to gear up! You've gone through the setup phase, getting everything ready for your Obby journey. From setting up your workspace to getting familiar with the tools, you're all set to unleash your creativity!
Now, let's dive into Stage 1 and start building your very own Obby masterpiece! Are you ready? Let's do this! ð
Objective ð§ðŋâ
Welcome to the first stage of our exciting Obby adventure! Get ready to climb to new heights as we conquer the Ascending Walls!
Description ððŠķâ
Hey there, fearless coders! Are you ready to take on the ultimate challenge and show off your coding prowess? Get ready to conquer the Ascending Walls like never before!
We are going to create a script that makes a part in Roblox move up and down between two heights. Here's what we want to accomplish:
1. Start at a Position:
The part will start at a certain position.
2. Move Up and Down:
The part will move up to a maximum height, then move down to a minimum height, and keep repeating this movement.
3. Direction Change:
When the part reaches the maximum height, it will change direction and start moving down. When it reaches the minimum height, it will change direction and start moving up again.
4. Smooth Movement:
The part will move smoothly, pausing for a short time during each step of movement.
By doing this, the part will continuously move up and down in a loop, creating a nice animation effect.
Instructions and Code Logic ððâ
Step 1 - Set Up Starting Variablesâ
-
Create a variable to hold the part by setting it to the
Parent
of the script. -
Make a variable to remember the starting position of the part.
-
Create variables for the highest point (
maxHeight
), lowest point (minHeight
), and how fast it moves (speed
). -
Create a true/false variable (
goingUp
) to know if the part is moving up, starting withtrue
.
Step 2 - Make an Infinite Loopâ
- Use a loop that runs forever. In Lua, this is done with
while true do
.
Step 3 - Check the Directionâ
- Inside the loop, use an
if
statement to see if the part is moving up. This is checked using thegoingUp
variable.
Step 4 - Move the Part Upâ
-
If
goingUp
istrue
, change the part's position to move it up. Use a vector to do this. -
Specifically, add to the Y-coordinate by the speed value.
Step 5 - Check Maximum Heightâ
-
After moving the part up, check if the part's Y-coordinate has reached or gone above the
maxHeight
. -
If it has, set
goingUp
tofalse
to start moving down.
Step 6 - Move the Part Downâ
-
If
goingUp
isfalse
, change the part's position to move it down. Use a vector to do this. -
Specifically, subtract from the Y-coordinate by the speed value.
Step 7 - Check Minimum Heightâ
-
After moving the part down, check if the part's Y-coordinate has reached or gone below the
minHeight
. -
If it has, set
goingUp
totrue
to start moving up again.
Step 8 - Pause the Loopâ
- Use the
wait
function to pause the loop for a short time, like 0.1 seconds, before repeating the loop.
Putting It All Together ð§ðĐâ
-
Start by setting up your starting variables.
-
Create an infinite loop using
while true do
. -
Inside the loop, use an
if
statement to check the direction (goingUp
). -
If
goingUp
istrue
, move the part up by adding to its Y-coordinate using a vector. -
Check if the part's Y position has reached the maximum height. If it has, set
goingUp
tofalse
. -
If
goingUp
isfalse
, move the part down by subtracting from its Y-coordinate using a vector. -
Check if the part's Y position has reached the minimum height. If it has, set
goingUp
totrue
. -
Use the
wait
function to pause the loop for a short time. -
Repeat the loop to keep the part moving up and down.
Medium: Ride the walls up and down using cool functions!
Description ððŠķ
We are going to create a script that makes a part in Roblox move up and down continuously.
Here's what we want to accomplish:
1. Move Up and Down:
The part will move up to a maximum height and then move back down to a minimum height.
2. Smooth Movement:
The movement will be smooth and continuous.
By doing this, the part will create a smooth up and down animation effect.
Instructions and Code Logic ðð
Step 1 - Set Up the Starting Variables
-
Create a variable for the part by setting it to the
Parent
of the script. -
Set the maximum height the part will move up to (
maxHeight
). -
Set the minimum height the part will move down to (
minHeight
). -
Set the speed of the movement (
speed
). -
Create a boolean variable (
goingUp
) to control the direction of movement.
Step 2 - Create the Functions
-
Define a function named
moveUp
. -
Inside the function, create a loop that runs while
goingUp
is true. -
In each loop iteration, move the part up by adding to its Y-coordinate.
-
If the part's Y-coordinate reaches or exceeds
maxHeight
, setgoingUp
to false and callmoveDown
. -
Use the
wait
function to pause the loop for a short time. -
Define a function named
moveDown
. -
Inside the function, create a loop that runs while
goingUp
is false. -
In each loop iteration, move the part down by subtracting from its Y-coordinate.
-
If the part's Y-coordinate reaches or goes below
minHeight
, setgoingUp
to true and callmoveUp
. -
Use the
wait
function to pause the loop for a short time. -
Call the
moveUp
function to start the up and down movement.
Putting It All Together ð§ðĐ
-
Start by setting up your part and movement properties.
-
Define functions to handle the continuous up and down movement.
-
Use the
wait
function to pause the loop during each iteration. -
Call the
moveUp
function to start the movement.
Hard: Smoothly animate the movement with a Roblox Service!
Description ððŠķ
We are going to create a script that makes a part in Roblox move up and down continuously using tweens. Here's what we want to accomplish:
1. Move Up and Down:
The part will move up to a maximum height and then move back down to a minimum height.
2. Smooth Movement:
The movement will be smooth and continuous using tweens.
By doing this, the part will create a smooth up and down animation effect.
Instructions and Code Logic ðð
Step 1 - Set Up the Starting Variables
-
Get the
TweenService
from the game. -
Create a variable for the part by setting it to the
Parent
of the script. -
Set the maximum height the part will move up to (
maxHeight
). -
Set the minimum height the part will move down to (
minHeight
). -
Set the duration of the tween (
tweenTime
).
Step 2 - Create the Functions
-
Define a function named
createTween
that takes a target position as an argument. -
Inside the function, set up the tween information (duration, easing style, direction).
-
Create and return the tween to move the part to the target position.
-
Define a function named
moveUpDown
. -
Inside the function, create a tween to move the part up to the maximum height.
-
Play the tween.
-
Connect a function to the
Completed
event of the tween to create and play a tween that moves the part down to the minimum height. -
Connect a function to the
Completed
event of the down tween to recursively callmoveUpDown
and continue the movement. -
Call the
moveUpDown
function to start the up and down movement.
Putting It All Together ð§ðĐ
-
Start by setting up your part and movement properties.
-
Define functions to create tweens and handle continuous movement.
-
Use the
wait
function to pause the loop during each iteration. -
Call the
moveUpDown
function to start the movement.
- Congratulations! You've conquered Stage 1 like a true coding champion! Now, gear up for even more thrilling challenges as we dive into Stage 2! Let the coding adventure continue! ðð