User:JulienDethurens/Draft: Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>JulienDethurens
I am completely rewritting the article about VIP doors. It will explain them with a new concept, restrictions that you can choose to apply or not.
>JulienDethurens
Blanked the page
 
(14 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Introduction ==


Restricted doors, also commonly called <abbr title="Very Important Person">VIP doors</abbr>, are used to restrict access to a certain area to only certain users. There are many restrictions that one could want to apply to a restricted door, and this article can not cover them all. It will however cover the most common restrictions:
*Being in a specific list.
*Owning a certain asset (usually a t-shirt, but can also be a badge, a shirt, or even a hat).
*Being in a specific group.
*Being the creator of the place.
*Being a friend or best friendss of a certain player or of the creator.
However, you should always think before making a restricted door that restricts access to a certain area. Ask yourself these questions:
*Is it really necessary?
*Wouldn't it be better to make a GUI or a command that teleports there?
*Isn't there a nicer way to do it?
The problem is that restricted doors are often overused. Sometimes, they are used to protect a room that contains certain items. Yet, these items could be given automatically to the players, instead of them having to enter the room every time they die. Try to avoid using a restricted door if you can do it in a cleaner way.
== Building the Door ==
[[File:Door.png|thumb|An example of a door.]]
Building the door should not be a problem, but I am still going to describe it. First, you will need to create the door. Usually, you will want it to be of the size of a character, so players can get through. You will probably want the door to be anchored too, unless you expect it to move whenever a player touches it...
The size of a player's character is 4 x 5 x 1, so you will probably want your door to have that size. However, you can't get exactly that size with the Brick [[FormFactor (Enum)|FormFactor]]. Therefore, you will probably want to change the FormFactor to Symmetric, so you can get the exact size. Another solution would be to simply make the door slightly bigger than the exact size of a character. Usually, you will also want to build a room around the door, but that is out of the scope of this tutorial.
== Scripting the Door ==
First, we will need to create a script in the door. Go in the "Insert" menu and choose "Object...". Then, use the dialog that appears to insert a script in the door. Once you have a script in your door, open it to edit it in the script editor.
Because the door will be manipulated a lot in the script, it would be a good idea to define a variable that contains a reference to it. I'll call that variable <var>door</var>, but you can call it whatever you want.
<code lua>
local door = script.Parent
</code>
You will probably want to be able to open and close the door. Let's make a function to open the door and another to close it.
There are many ways to open a door, but, for this tutorial, we will choose one that makes the door progressively disappear.
We will use a loop to make the door fade, and we will use its [[Transparency (Property)|Transparency]] property to changnale its opacity. Then, finally, we will change the door's [[CanCollide (Property)|CanCollide]] property to allow players to walk through it.
Incase you weren't sure how to write the code, here is an example that works. However, you are encouraged to write your own code, as that is how you will learn.
<code lua>
function open()
-- This function will open the door.
door.CanCollide = false -- Make players able to walk through the door.
for transparency = 0, 1, .1 do
door.Transparency = transparency
wait(.1)
end
end
</code>
If there is an open function, there is of course also a close function. That close function does exactly the opposite of what the open function does, so you should be able to write the code yourself. If not, here is the code as I wrote it, but remember you are encouraged to write it yourself:
<code lua>
function close()
-- This function will close the door.
for transparency = 1, 0, -.1 do
door.Transparency = transparency
wait(.1)
end
door.CanCollide = true -- Make players unable to walk through the door.ss
end
</code>

Latest revision as of 19:39, 22 April 2012