How to create a scary elevator in Roblox – training for schoolchildren

In Roblox Studio, kids can create 3D games of various genres. One of the most popular modes is horror: test rooms, scary labyrinths, towers, traps and other horror films. In this tutorial we want to tell you how to create a map with a dangerous elevator.

Lesson prepared by online programming school for children Pixel. At the end of the material we will leave a video that will help you better understand the tutorial.

If you're just getting started with Roblox Studio and the Lua language, check out the series video lessons for beginners. The videos will help you install applications on your PC, understand the structure of the program and the principle of writing scripts.

Beginning: creating an elevator in Roblox Studio – the essence of the game

This game is a set of scary levels, between which the player moves by elevator. The user on our map will have to collect items that will add score points to him, and keys that will open the elevator to new locations. Let's learn how to make an elevator and the items necessary for the game.

Account programming

Let's create a player account by adding the following script to the ServerScriptService folder:

Let's look at it in more detail: when a player is added, our function will be triggered, to which we pass the player object. 3 variables are created: leaderstats folder, 2 numeric values ​​score and keys.

This script will allow you to display accumulated points and collected keys.

Creating objects and scripts: key, coin

Let's create objects that the player will collect. Let's start with the key.

We will use solid modeling tools to form the key ring. Let's create 2 cylinders: the small one will be inside the large one, we will make it the negative part by clicking on the corresponding button in the Model section. After combining with the Union tool, the negative part inside will disappear and we will get a ring. The remaining parts of the key can also be connected using Union.

Let's add the following script to our key:

Let's look at the essence of the code: when there is contact with an object, we will call a function to which we will pass the contact. Let's find the corresponding player and check in the conditional construction whether he exists, and in this case we will add one to the key count, after which we will delete the object.

Next, we will find the mesh model of the coin and add a similar script to it, but in it we will replenish the account, and not the number of keys.

Creating an elevator

It's time to add the main element – the elevator. To begin with, we will create the cabin of the lifting device using solid-state modeling. Similar to the ring in the key, we will create a cavity in the desk (Part):

We will build doors from two desks.

Let's combine these blocks into a model. We will definitely rename the components: cabin – Cabin, left door – Door1, right door – Door2. Let's not forget to name the model Elevator and add a script to it.

Our elevator should wait for us and take us to the next floor only after we have collected a certain number of points. Let's take a closer look at the elevator script.

Roblox elevator code

Roblox elevator code

  1. At the very beginning, we will define the variables for the cabin and two doors. After this, we will create the openDoors() function. In it, we will use a cycle to move one door to the left side, and the other to the right. The closeDoors() function works similarly, only in it we move the doors in the opposite direction to close them.

  1. Create a local variable isOpen. Initially it is set to true – this means that the doors are open. Then we open the door to the cabin and subscribe our function to the Touched event, transferring the player to it. We check if there is a player. If the doors are open and the player has three or more keys, then we set the isOpen variable to false so that the elevator will no longer open. Then we wait one second, close the door and use a cycle to move our lifting device up. After that, open the door again.

Now we can change the height of the elevator movement by changing the number of iterations in the lifting loop. And also change the check condition to the number of keys. Using these objects and elevators, you can make a horror game in which the player will move on an elevator, collecting points and keys for the elevator.

If you managed to complete all the steps in the instructions and create an elevator, send links to your maps in the comments, and we will evaluate them.

Video: how to make a scary elevator in Roblox

Watch the instructions to see the project in action and listen to the instructor explain.

***

The material was prepared by the children's IT school Pixel. If you want to learn more about programming in Roblox, check out our online course for schoolchildren 9-14 years old. And also watch free video tutorials on any platform: RuTube, YouTube, VK, Zen.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *