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

Sliding Door, Why won;t it go down?

Asked by 9 years ago

I am trying to get the door to slide down .

DoorSystem = script.Parent --The Model
Door = DoorSystem.Door1 --The Door's Name
DoorPad = DoorSystem.DoorPad1 -- The Door Pad
local padPressed = false --Do not touch this variable

function Slide()
    if not padPressed then
        padPressed = true
        for i = 1, 85 do --Keep on changing the number 31 until the Part goes in properly. 
            Door.CFrame = Door.CFrame + Vector3.new(0, 0.1, 0)
            wait()
        end
        wait(3)--Play around with this until it works
        padPressed = false
        if padPressed then
            for i = 1, 85 do
                Door.CFrame = Door.CFrame - Vector3.new(0, -0.1, 0) --I am trying to get it to slide down 
            end
        end
    end
end

DoorPad.Touched:connect(Slide)

1 answer

Log in to vote
0
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
9 years ago

Subtracting a negative number and adding a positive number is the same thing. Therefore, line 17 needs to be:

Door.CFrame = Door.CFrame - Vector3.new(0, 0.1, 0)

or

Door.CFrame = Door.CFrame + Vector3.new(0, -0.1, 0)

Also, since you set padPressed to false right before you check if it's true, obviously that if statement will not be true (resulting in the code inside the if statement not running).

Ad

Answer this question