Skip to main content

Stage 4: KillBrick Path

info
Prerequisites: Before You Dive In!

Before you dive into the excitement of Stage 4 and conquer the challenging Killbrick Path, make sure you've conquered these thrilling adventures:

1. Intro

You've embarked on this coding journey with eagerness and excitement, now get ready to take it up a notch!

2. Setup

You've laid the groundwork for your Obby adventure, ensuring everything is ready for your creative genius to shine.

3. Stage 1: Ascending Walls

You've scaled heights and overcome obstacles, mastering the basics of obstacle creation. Now, let's push those boundaries even further!

4. Stage 2: Sphere Stairs

You've navigated through spheres and conquered stairs, showcasing your building skills. Get ready to elevate your game even more!

5. Stage 3: Plank Walkway

You've walked the plank with finesse, creating a path of adventure. Now, let's gear up for the next challenge and keep the excitement going!

You're all set and pumped up to tackle Stage 4 like a true Obby champion! 🚀


Objective 🧐ðŸ—ŋ​

Welcome to the adrenaline-pumping fourth stage of our Obby! Get ready to unleash your creativity as we construct the thrilling KillBrick Path.

Description 📖ðŸŠķ​

Hey fearless adventurers! Stage 4 just got a whole lot trickier, but I know you're up for the challenge! Get ready to add an extra twist to the KillBrick Path by setting those bricks in motion. Remember, your Code Coach is here to help, but if you tackle this challenge solo, you'll earn some serious bonus points!

We are going to create a script that makes a brick in Roblox grow and shrink continuously. Additionally, when a player touches the brick, it will cause the player's character to lose all health. Here's what we want to accomplish:

1. Start with a Brick:

We have a brick that starts at a certain height.

2. Grow and Shrink:

The brick will grow taller until it reaches a maximum height, then shrink back to its original height, and keep repeating this process.

3. Player Touch Detection:

If a player touches the brick, their character will lose all health.

By doing this, the brick will keep growing and shrinking, and it will affect players when they touch it.

Instructions and Code Logic 📝📚​

Step 1 - Set Up the Starting Variables​

  • Create a variable for the brick by setting it to the Parent of the script.

  • Create a variable to remember the original height of the brick.

  • Create a variable for the maximum height the brick can grow to (maxHeight).

  • Create a variable for how fast the brick will grow and shrink (speed).

  • Create a true/false variable (isAscending) to know if the brick is growing, starting with true.

Step 2 - Create a Function​

  • Define a function named PlayerTouched that takes a part (Part) as an argument.

  • Inside the function, check if the part's parent is a player's character.

  • If it is, set the player's character's health to 0.

Step 3 - Connect the Function​

  • Connect the PlayerTouched function to the brick's Touched event.

Step 4 - Make an Infinite Loop​

  • Create a loop that runs forever using while true do.

Step 5 - Grow the Brick​

  • Inside the loop, check if isAscending is true.

  • If it is, create another loop to make the brick grow taller until it reaches maxHeight.

Step 6 - Shrink the Brick​

  • If isAscending is false, create another loop to make the brick shrink back to its original height.

Step 7 - Pause the Loop​

  • Use the wait function to pause the loop for a short time during each step of growing and shrinking.

Step 8 - Change Direction​

  • After the brick has grown to maxHeight, set isAscending to false to start shrinking.

  • After the brick has shrunk to its original height, set isAscending to true to start growing again.

Putting It All Together 🔧ðŸ”Đ​

  • Start by setting up your brick and other variables.

  • Define a function named PlayerTouched to handle when a player touches the brick.

  • Connect the PlayerTouched function to the brick's Touched event.

  • Create an infinite loop using while true do.

  • Inside the loop, make the brick grow if isAscending is true.

  • If isAscending is false, make the brick shrink.

  • Use the wait function to pause the loop during each step.

  • Change the direction of growth when the brick reaches the maximum or original height.

Medium: A moving kill brick that bounces up and down, taking body parts with it!

Description 📖ðŸŠķ

We are going to create a script that makes a brick move up and down continuously and reduce the health of any player who touches it. Here's what we want to accomplish:

1. Move Up and Down:

The brick will move up to a certain height and then move back down to its original height.

2. Detect Touch:

If a player touches the brick, their health will be reduced, and the part they touched will be destroyed.

By doing this, the brick will create a dynamic interaction where it moves up and down and affects players who touch it.


Instructions and Code Logic 📝📚

Step 1 - Set Up the Starting Variables

  • Create a variable for the brick by setting it to the Parent of the script.

  • Store the original height of the brick.

  • Set the maximum height the brick will move up to (maxHeight).

  • Set the speed at which the brick will move (speed).

  • Create a boolean variable (isAscending) to control the direction of movement.

Step 2 - Create a Function

  • Define a function named moveUpAndDown.

  • Inside the function, create a loop that runs forever using while true do.

  • Inside the loop, check if isAscending is true.

  • If true, create another loop to make the brick grow taller until it reaches maxHeight.

  • If false, create another loop to make the brick shrink back to its original height.

  • Use the wait function to pause the loop for a short time during each step of growing and shrinking.

  • Define a function named PlayerTouched that takes a part (Part) as an argument.

  • Inside the function, get the parent of the touched part (which should be a player's character).

  • Check if the parent is a player's character.

  • If it is, reduce the player's health by 10 and destroy the touched part.

  • Connect the PlayerTouched function to the brick's Touched event.

  • Call the moveUpAndDown function to start the up and down movement.


**Putting It All Together 🔧ðŸ”Đ **

  • Start by setting up your brick and movement properties.

  • Define functions to handle the continuous movement and player touch.

  • Connect the PlayerTouched function to the brick's Touched event.

  • Use the wait function to pause the loop during each iteration.

  • Call the moveUpAndDown function to start the movement.

Hard: A swinging pendulum kill brick for extra thrills!

Description 📖ðŸŠķ

We are going to create a script that makes a brick in Roblox move like a pendulum. Here's what we want to accomplish:

1. Pendulum Motion:

The brick will swing back and forth like a pendulum.

2. Smooth Movement:

The motion will be smooth and continuous.

By doing this, the brick will create a realistic pendulum motion effect.


Instructions and Code Logic 📝📚

Step 1 - Set Up the Starting Variables

  • Create a variable for the brick by setting it to the Parent of the script.

  • Store the current position of the brick as the pivot point (pivotPosition).

  • Define the maximum angle from the vertical in degrees (amplitude).

  • Set the speed of the pendulum swing (speed).

Step 2 - Create a Function

  • Define a function named movePendulum.

  • Inside the function, record the start time using tick().

  • Create a loop that runs forever using while true do.

  • Inside the loop, calculate the elapsed time since the start.

  • Calculate the angle for the pendulum based on the elapsed time using the sine function.

  • Convert the angle from degrees to radians.

  • Calculate the new CFrame for the brick based on the pivot point and the calculated angle.

  • Update the brick's CFrame to the new calculated CFrame.

  • Use the wait function to pause the loop for the next frame.

  • Call the movePendulum function to start the pendulum motion.


Putting It All Together 🔧ðŸ”Đ

  • Start by setting up your brick and pivot position.

  • Define the pendulum properties such as amplitude and speed.

  • Create a function named movePendulum to handle the pendulum motion.

  • Inside the function, calculate the new positions and update the brick's CFrame to create the pendulum effect.

  • Use the wait function to pause the loop during each iteration.

  • Call the movePendulum function to start the movement.


Congratulations! You've completed Stage 4 with flying colors! Now, gear up and get ready to conquer Stage 5 with even more excitement and determination! You're one step closer to Obby mastery! 🌟

robloxGigaChad