How To Make An Animated Door (Click To Open)

You’ll want to make the parts that are supposed to be named “DoorClose” and “DoorOpen” transparent.

1 Like

Yeah, but you said turn the transparency to 0.

When you turn the transparency to 0, it turns visible.
when you turn it to 1, it turns invisible.

1 Like

Oops! Thank you for pointing that out, that was error in my typing.

1 Like

no, problem

everyone does mistakes once in a while :slight_smile:

1 Like

I feel as though this would be better suited for Community Resources - this is not a tutorial on making a door so much as it is a tutorial on how to copy and paste code.


thanks for teaching me, now I know how to make a door!

1 Like

Maybe you could make it a bit more advanced and have the door go to a certain side depending on what side of the door you click on.

Do you mean as in a double door?

No, I mean as if you click on one side it opens to the other, and if you click on the other side, it opens the other side.

Very helpful for beginners! Thanks for sharing!:+1:

1 Like

Bad tutorial, bad code, something in Toolbox I could find, also using wait() as debounce, doesn’t seems good tbh.

You probably shouldn’t serverside the tween. You should have it local and replicate the local tween across all clients. Serverside tweens can be laggy and just be… bad.


When I said that I didn’t expect you to take it at face value. It should go without saying that when phrased as a “faux-tutorial” this should be in community tutorials, however it serves more benefit reimagined as a community resource.

1 Like

Well, that wasn’t exactly a tutorial. I’m a beginner and would like to understand how the script works, not copy and paste. But thanks for sharing your knowledge.

1 Like

I thought it was a fine beginner level tutorial which shows a simple way of animating a door. Do you have any specific questions about the script used? It uses a click detector event to fire the function which uses tweenservice to animate the door(update the visible door’s CFrame) from the CFrame of the invisible closed door part, to the CFrame of the invisible opened door part. CFrame is the position and orientation of the parts.


This seems like a really nice tutorial for beginners but, if anyone wanted to make a actual game, I wouldn’t recommend this, instead, I’d recommend using module scripts and, not using multiple ClickDetectors since they may use more resources than needed, instead, you can change the parent of your ClickDetector and, a while true do loop to do a magnitude check; if a door is within x amount of studs (e.g. 7), change the parent of your ClickDetector and, if it’s clicked, fire a remote event to the server where an animation will be played based on the state of the door (open/closed), also, remember to do sanity checks on the server too.

Note: I’d recommend adding sanity checks since exploiters can fire ClickDetectors without being close to one (this is assuming you handle ClickDetector.MouseClick events on the server).


Thank you! I don’t know how to use the tweenservice, but I’ll see it. I’m watching TheDevKing tutorial by the the way.

When I see the tutorial I’ll come back here, thanks for helping me!

1 Like

Hello everyone! As of January 2021, attributes have been released to beta users and will be released to all users very soon.

With this, we’re not entirely sure what will happen to the value objects themselves. They may be removed, or they may stay (although, with attributes being released there’s not really a point of keeping them unless attributes don’t cover everything that the value objects do).

Therefore, in case value objects are removed and this tutorial becomes outdated, this reply will be showing you how to edit your door model so that it uses attributes to replace the BoolValue.

For this, I will simply be using the door model that I have prepared already.

Let’s start by going back to the children in the explorer tab:

First, delete the BoolValue (which is named Opened) if it still exists at the time of you reading this.

Then, click on your model (the icon with the three colored bricks). In the properties tab, you’ll want to click on “Add Attribute”

That should bring up this menu:
Screenshot (9)

For the name, you’ll want to name it whatever the BoolValue was named before. If you’re using my door model, the name should be “Opened.”

For the type, open the dropdown menu (by click on “string”) and select “boolean.” Then hit “Save” and you should see something like this in the properties tab:
Screenshot (11)

Keep the box next to the attribute unchecked, just like the BoolValue was before.

Editing The Script

I have realized that the way I “taught” you the script wasn’t very efficient. Especially because my teaching method was:

This was my first tutorial and therefore I have realized there’s a lot of areas to improve in.

I will get into more detail about what this script is after I show you what to edit.

You can find the script in the part called “DoorPart.”

When you double click on the script, this is what you’ll see:

local frame = script.Parent
local clickDetector = frame:WaitForChild("ClickDetector")
local model = frame.Parent
local Close = model:WaitForChild("DoorClose")
local Open = model:WaitForChild("DoorOpen")
local opened = model:WaitForChild("Opened")
local tweenService = game:GetService("TweenService")
local debounce = true
    if debounce == true then
        debounce = false
        if opened.Value == true then
            opened.Value = false
            tweenService:Create(frame,,{CFrame = Close.CFrame}):Play()
            opened.Value = true
            tweenService:Create(frame,,{CFrame = Open.CFrame}):Play()
        debounce = true

This script uses a click detector that when clicked, fires a tweenservice which animates the door to animate open. We use the invisible parts to determine the position we want the visible door frame to move.

Sir_Highness explained it in a little more detail than I did:

If you want to learn about TweenServices and/or CFrame, I recommend two AlvinBlox tutorials:

Now, into the script

First, look at the 6th line of code:

local opened = model:WaitForChild("Opened")

This line of code is what originally created a local variable for the BoolValue that was named “Opened.” However, since there is no longer a BoolValue in the script, there’s nothing that can be referred to as “opened” so the script won’t work.

But why do we have to change it? Isn’t the attribute the child of the door model?

Incorrect, attributes are stored in the properties tab of an object. That’s why they are much more efficient. Because if you’re doing things like making a gun, you can put what’s worth 8 objects into just 1 using attributes, which will save space and keep things organized.

To replace this line so that it will get the attribute, simply delete “:WaitForChild” and replace it with “:GetAttribute” (assuming that you named the attribute the same name that the BoolValue was).

Next, you’ll want to get rid of every “.Value” in the script (which can be found on lines 13, 14, and 18 assuming you and I are using the same script).


Since attributes aren’t objects, they don’t have special property tabs individually. Therefore, when using “opened.Value” the script will attempt to index a boolean with a Value. In other words, it will attempt to find the properties for something that doesn’t have properties.

I’m not giving away what the fixed script should look like OR the model of the fixed version because:

  1. Attributes aren’t accessible to everyone at the time of posting this
  2. I’ve realized that if I just give you everything you aren’t learning.

This does not mean I will be taking down the original model, that will stay up.

Hopefully, this helps and will provide a better inside on the script! Have a great day!

Can you update this with proximityprompt?


Then can you give a code that we should use instead? :thinking: