Roblox Studio Tutorials - June 6, 2022

How to Open a Door When Clicked


Buzzy Beth


Download – Door Script

How To – Open a Door When Clicked

What’s up everyone, BuzzyBeth here – In this tutorial we’ll be learning how to open a door when it’s clicked!

  • Inside of our workspace create our door, now if you already have a door this definitely works for it too. Make sure to not anchor this door by the way. Rename this part to “door”, do not anchor it.
  • Next up we’re going to go ahead and spawn in another part and this is going to be our “hinge”. For our hinge go ahead and customize it to however you would like and then rename that part to “hinge”. For our hinge make sure to anchor it.
  • Inside of our door part let’s go ahead and add a weld constraint object. For part zero we’re gonna weld the door and then part one we’re going to weld the hinge.
  • For our hinge we’re gonna actually go ahead and set the transparency of it to one and then we’ll be duplicating that exact hinge. This time i’m going to set the transparency of it(duplicated hinge part) back to zero and then i’m going to go ahead and actually rename this duplicated part to just “part”.
  • The reason i’m doing this is because later when we tween it the hinge, if we don’t have this duplicated part it’s just gonna look glitchy any time the tweening occurs. So we’re just going to set the transparency of it to one. Go ahead and group all of our parts into a model now. Inside of our door let’s go ahead and add a click detector because we wan tto click the door and then of course let’s go ahead and add a script inside of our model.
  • We have a few variables which references our tween service, the hinge part, our click detector, as well as a debounce. We’re going to go ahead and get the current hinge CFrame and multiply it so that it opens our door by 90 degrees and then we’re going to set a variable that closes the door and resets the position of our part.
  • Now we’re going to go ahead and set our tween information forwhen the door opens and closes.
  • Create a function where any time a player clicks on our part then the tweetinformation is going to play and when we click on the door again, then the closed door animation is going to play.