Introduction
Hello, welcome to this resource you may consider calling a tutorial if you wish. If you are a pro at scripting, I urge you to click off this topic. If you are a beginner to scripting (Know little or don’t know any scripting things of that nature) then welcome! Here I will cover some basic scripting with a step-by-step guide! Let’s get started!
Table of Contents
- Part 1: Building the trap
- Part 2: Inserting the script + explorer introduction
- Part 3: Variables and shortcuts
- Part 4: Functions, waits, CanCollide
- Part 5: Transparency and code roundup
- End and recommended plugins
Part 1: Building the trap
This part is optional. Scroll down if you already have something to build off of, or don’t wanna make it. But here we go!
It’s just an empty small map. Let’s change that!
Try to make something like this to start.
Then insert a cylinder as shown in the picture.
Next, make a small, floorless cage thing.
make a red, diamond plate floor for that floorless cage now. Should be easy not including picture.
make rocks of your choice in the cage, MAKE SURE THERE ARE NO WELDS AND ARE NOT ANCHORED FOR THE ROCKS BEHALF.
Part 2: Inserting the script + explorer introduction.
So now we came to our next part! Congrats! however, that doesn’t mean it gets easier… Insert a script! What? You don’t know how? OK. Go into: View < explorer! now in the trapdoor part (red, diamond plate part) click the little plus to the side and insert a script. Call it “TrapdoorScript”.
Part 3: Variables and shortcuts
Variables allow you to use one thing and use it throughout one script as a shortcut instead of writing “script.Parent” over and over, variables are quite useful, we will be covering them throughout this part!
Start by adding the following:
local Trapdoor
It’s a good start! but it doesn’t contain anything to make us a shortcut. So continue off your variable like this:
local Trapdoor = script.Parent
PLEASE MAKE SURE YOUR SCRIPT IS PARENTED TO THE TRAPDOOR PART.
Now you have a variable for a shortcut! now, here’s a shortcut, press tab when your ready to auto finish intended parts for the script (sometimes doesn’t do this).
Part 4: Functions and CanCollide
Ever wondered how you moved through some objects in some games? Ever wondered how the same piece of code is useful in other parts of one script? This part covers that!
Lets complete the essentials to our script, it should look like this:
local Trapdoor = script.Parent
local function openTrapdoor()
wait(5)
Trapdoor.CanCollide = false
end
The function allows it to be used throughout our script multiple times, it does nothing right now, but in the next and last part we will finish the script so it does what it needs to do.
Part 5: Transparency and code roundup
The part you’ve all been waiting for, the finish of the script! Here, we will find out about transparency properties and the finished code(code roundup). Let’s get into it!
First, we need to answer the question, “What is the Transparency property?” Well, transparency determines whether you can see an object, or not. Transparency 0 you can perfectly see it. But Transparency 1 makes it entirely invisible. Anything in-between is a little see through.
Now let’s put it in our function. Heres what the function part of our script should look like:
local function openTrapdoor()
wait(5)
Trapdoor.CanCollide = false
Trapdoor.Transparency = 1
end
IMPORTANT: if you want organized code, keep the indents that the script made for you!
Now when we run it- Wait… It doesn’t do what it’s supposed to! Try this:
while true do:
wait(0.7)
openTrapdoor()
end
It should work now! Here’s our final code:
local Trapdoor = script.Parent
local function openTrapdoor()
wait(5)
Trapdoor.CanCollide = false
Trapdoor.Transparency = 1
end
while true do
wait(0.7)
openTrapdoor
end
End and recommended plugins
This wraps up our code, feel proud, you made an advancement to be able to code, go out and make some awesome games! One more thing, a recommended plugin to help you develop, try installing the Studio+ plugin, not including a link cause it’s easy to find in the plugin library. Good luck new developers!