How to Open a Door When Touching a Part
Download – Door Script and Model
How To – Open a Door When Touching a Part in Roblox Studio
What’s up everyone, BuzzyBeth here – In this tutorial we’ll be learning how to open a door when touching a part!
- Inside of our workspace we’re going to go ahead and create our pressure plate. So that anytime a player steps on this the door is going to open.
- I’m going to go ahead and change the material of it so that it’s a diamond plate and change the color of it as well.
- Next up i’m gonna go ahead and create my actual door, this is just gonna be a pretty simple door nothing fancy just a part. Create a duplicate of that door and drag it so that it’s right above that part and then set the transparency of it to one.
- Highlight all ofour parts and group them inside so that it is a model. For our door part, we’ll be renaming that to “Door” and then the part that’s right above our door we’re going to rename that to “EndPos” which stands for end position. Then the part that we’ll be stepping on which is our pressure plate. i’ll be renaming that to “PressurePlate”.
- Once you’re done with that, go ahead and add an intvalue inside of our model and then rename that to “Time” and then set the value of it to two. It’s just telling us how long it’s going to take for the door to open and close.
- Now inside of our model let’s go ahead and add a script. We have a few variables which references our entire model the EndPos part, our actual door, the pressure plated, a debounce, as well as our tweenservice.
- We’re gonna go ahead and set the tween information. Set our time how many seconds we want our door to open and close as well as the easing style, easingdirection, how many time it repeats, and if we want our part to reverse etc.
- Create afunction where trigger is our parameter, we’re going to check if it’s a player and if it’s not activated then activated is going to be equal to true and then our tween information is going to play until our door part hits (reaches) the “EndPos” part. Then the debounce is going to equal to false and then we’ll call our function.