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

2 Price Is Right doors need to be combined?

Asked by 10 years ago

I have two doors, each with 8 panels. The first door opens halfway, for host entry. The second door opens fully, to present a prize. Each door has 4 separate scripts, controlling 2 panels.

Here is what I have so far:

Door 1, Panel set 1 (This is repeated to the other panel sets with different timings and different names):

DoorParts=script.Parent.DoorParts1
open=0
function onClick()
    if open==0 then
    open= 1

        for i=1,30 do
        wait(.02)
        DoorParts.B1.CFrame=DoorParts.B1.CFrame*CFrame.new(.15,0,0)
        DoorParts.B2.CFrame=DoorParts.B2.CFrame*CFrame.new(-.15,0,0)


        end
    --Gate is turned off

    open=1
    elseif open==1 then
    open=3

    --Gate is turned on

        for i=1,30 do
        wait(.08)
        DoorParts.B1.CFrame=DoorParts.B1.CFrame*CFrame.new(-.15,0,0)
        DoorParts.B2.CFrame=DoorParts.B2.CFrame*CFrame.new(.15,0,0)

        end



    open=0
    end
end

script.Parent.Button.ClickDetector.MouseClick:connect(onClick)

Door 2:

DoorParts=script.Parent.DoorParts1
open=0
function onClick()
    if open==0 then
    open= 0

        for i=1,30 do
        wait(.02)
        DoorParts.B1.CFrame=DoorParts.B1.CFrame*CFrame.new(.4,0,0)
        DoorParts.B2.CFrame=DoorParts.B2.CFrame*CFrame.new(-.4,0,0)


        end
    --Gate is turned off

    open=1
    elseif open==1 then
    open=3

    --Gate is turned on

        for i=1,30 do
        wait(.08)
        DoorParts.B1.CFrame=DoorParts.B1.CFrame*CFrame.new(-.4,0,0)
        DoorParts.B2.CFrame=DoorParts.B2.CFrame*CFrame.new(.4,0,0)

        end



    open=0
    end
end

script.Parent.Button.ClickDetector.MouseClick:connect(onClick)

I need help fusing these two together, so I can have two buttons on one door, one opening halfway, and one opening fully.

Answer this question