I have a grouped everything together. I also referenced this video: https://www.youtube.com/watch?v=ZnBz_kbSnm8&index=45&list=WL&t=1115s
-Automatic Door, Script, -Door1, Frame, Frame, Frame, Frame, Glass, -Door2, Frame, Frame, Frame, Frame, Glass, Frame (x11), Glass (x3), Sensor,
Script:
01 | door 1 = script.Parent.Door 1 |
02 | door 2 = script.Parent.Door 2 |
03 |
04 | doorClosed = true |
05 |
06 | script.Parent.Sensor.Touched:connect( function (hit) |
07 | local h = hit.Parent:FindFirstChild( "Humanoid" ) |
08 | if h then |
09 | if doorClosed then |
10 | doorClosed = false |
11 | for i = 1 , 30.3 do |
12 | door 1. CFrame = CFrame.new(door 1. Position + Vector 3. new( 0 , 0 , 0.3 )) |
13 | door 2. CFrame = CFrame.new(door 2. Position + Vector 3. new( 0 , 0 ,- 0.3 )) |
14 | wait() |
15 | end |
Please help me, thank you.
First off, output is the information that the program processes and sends out. Print() is the easiest and simplest output function.
The easiest way to make a sliding door is not with CFrame, but with a PrismaticConstraint. Simply attach one attachment to the door, and one to the wall it is sliding from, and put a PrismaticConstraint in between. Then, change the ActuatorType to Servo, mess around with the settings a bit until you get what you like, change the TargetPosition to 0, and put the following code in your script:
01 | door 1 = script.Parent.Door 1 |
02 | prismatic 1 = door 1. PrismaticConstraint |
03 | door 2 = script.Parent.Door 2 |
04 | prismatic 2 = door 2. PrismaticConstraint |
05 | --Assuming that you already have the PrismaticConstraints installed correctly, that is... |
06 |
07 | doorClosed = true |
08 |
09 | script.Parent.Sensor.Touched:connect( function (hit) |
10 | local h = hit.Parent:FindFirstChild( "Humanoid" ) |
11 | if h and doorClosed then |
12 | doorClosed = false |
13 | prismatic 1. TargetPosition = 45 --or whatever you want |
14 | prismatic 2. TargetPosition = 45 |
15 | wait() --however long it takes for your doors to open |
See how much cleaner that looks using a Constraint instead of a CFrame?