Introduction to Coding
Part 1 - Getting Started
Introduction to Coding
Part 1 - Getting Started

In Introduction to Roblox Studio, you learned how to create and manipulate parts in Roblox Studio. It’s time to use code to make them do things.

In this project, you’ll use a script to make a platform appear and disappear. You could use this in a platforming game to span a gap, challenging players to time their jumps carefully to get to the other side.

Setting the Scene

First off, you’ll need a Part to act as the platform. Making and moving parts should be familiar to you from Introduction to Roblox Studio. You don’t need a complicated game world aside from the platform — you just need a gap that your players can’t quite jump across.

  1. Insert a Part and give it a name like DisappearingPlatform.

  2. Resize it so that it’s big enough for a player to jump on.

  3. Move it so that you can reach it and jump on it when testing the game.

  4. Set the Anchored property to true in the Properties window.

Inserting a Script

Code in Roblox is written in a language called Lua and is stored and run from scripts. You can put scripts anywhere — if you put a script in a part, Roblox will run the code in the script when the part is loaded into the game.

  1. Hover over your Part in the Explorer and click the button.

  2. Select Script from the menu which appears — this will insert a new script into the platform. Call your new script Disappear.

  3. Delete the default code inside.

Naming Scripts and Parts

Remember to rename parts and scripts as soon as you create them so you don’t lose track of things in the Explorer.

First Variable

It’s a good idea to start off your script by making a variable for the platform. A variable is a name associated with a value. Once a variable is created, it can be used again and again. You can change the value as needed.

In Lua, a variable is created as follows: local variableName = variableValue.

The term local just means that the variable is only going to be used in this part of the script. The = sign is used to set the value of the variable.

  • Copy the code below to create a variable for the platform called platform. where the value is script.Parent.
local platform = script.Parent

script.Parent is used to find the object the script is located in. As you might have guessed, script refers to the script you’re writing in and the Parent of the script is where it’s located.

Naming Variables

Names for variables are typically written in camel case. This is lowercase with every word following the first being capitalized, justLikeThis.

Next Page Functions