Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Sliding Door won't work. CFrame (Position + Vector3) not moving?

Asked by 8 years ago

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:

01door1 = script.Parent.Door1
02door2 = script.Parent.Door2
03 
04doorClosed = true
05 
06script.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                door1.CFrame = CFrame.new(door1.Position + Vector3.new(0,0,0.3))
13                door2.CFrame = CFrame.new(door2.Position + Vector3.new(0,0,-0.3))
14                wait()
15            end
View all 25 lines...

Please help me, thank you.

1
Is there any output? Have you added print()s to make sure the loops are starting at all? BlueTaslem 18071 — 8y
0
I have no clue what an output is. And I did not add print(). PvPNinjaDragon 35 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

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:

01door1 = script.Parent.Door1
02prismatic1 = door1.PrismaticConstraint
03door2 = script.Parent.Door2
04prismatic2 = door2.PrismaticConstraint
05--Assuming that you already have the PrismaticConstraints installed correctly, that is...
06 
07doorClosed = true
08 
09script.Parent.Sensor.Touched:connect(function(hit)
10    local h = hit.Parent:FindFirstChild("Humanoid")
11    if h and doorClosed then
12            doorClosed = false
13        prismatic1.TargetPosition = 45 --or whatever you want
14        prismatic2.TargetPosition = 45
15        wait() --however long it takes for your doors to open
View all 21 lines...

See how much cleaner that looks using a Constraint instead of a CFrame?

Ad

Answer this question