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

How do I make this door script open using Tween Service, instead of CFrame?

Asked by 5 years ago
Edited 5 years ago

I'm not sure how to make this Key Card door open using tween, instead of CFrame.

Here's the door code:

local door = script.Parent
local bool = true
local bool2 = true
local clearance = {
    ["Card-Omni"] = true, 
    ["Card-L5"] = true, 
    ["Card-L4"] = true,
    ["Card-L3"] = true,
    ["Card-L2"] = true,
    ["Card-L1"] = true,
    ["Armory Card"] = true,

}

function openDoor()
    script.Parent.DoorOpen:play()
    for i = 1,(door.Size.z / 0.30) do
        door.CFrame = door.CFrame - (door.CFrame.lookVector * 0.30)
        wait()
                end
    door.Transparency = 1
            for i,v in pairs(door:GetChildren()) do
                if v:IsA("Decal") then
                    v.Transparency = 1
        end
    end
    wait(3)
    door.Transparency = 0
            for i,v in pairs(door:GetChildren()) do
                if v:IsA("Decal") then
                    v.Transparency = 0
                end
            end
    script.Parent.DoorClose:play()
    for i = 1,(door.Size.z / 0.30) do
        wait()
        door.CFrame = door.CFrame + (door.CFrame.lookVector * 0.30)
        end
    end

script.Parent.Parent.KeycardReader1.touched:connect(function(touch)
    if touch.Name == "Handle" and clearance[touch.Parent.Name] and bool then
        bool = false
        script.Parent.AccessGranted:play()
        script.Parent.Parent.Light1.brickColor = BrickColor.new("Lime green")
        script.Parent.Parent.Light2.brickColor = BrickColor.new("Lime green")
        script.Parent.Parent.Light3.brickColor = BrickColor.new("Lime green")
        script.Parent.Parent.Light4.brickColor = BrickColor.new("Lime green")

        openDoor()
        wait(1)
        script.Parent.Parent.Light1.brickColor = BrickColor.new("Lily white")
        script.Parent.Parent.Light2.brickColor = BrickColor.new("Lily white")
        script.Parent.Parent.Light3.brickColor = BrickColor.new("Lily white")
        script.Parent.Parent.Light4.brickColor = BrickColor.new("Lily white")

        bool = true
    elseif touch.Name == "Handle" and not clearance[touch.Parent.Name] and bool2 then
        bool2 = false
        script.Parent.AccessDenied:play()
        script.Parent.Parent.Light1.brickColor = BrickColor.new("Really red")
        script.Parent.Parent.Light2.brickColor = BrickColor.new("Really red")
        script.Parent.Parent.Light3.brickColor = BrickColor.new("Really red")
        script.Parent.Parent.Light4.brickColor = BrickColor.new("Really red")
        wait(1)
        script.Parent.Parent.Light1.brickColor = BrickColor.new("Lily white")
        script.Parent.Parent.Light2.brickColor = BrickColor.new("Lily white")
        script.Parent.Parent.Light3.brickColor = BrickColor.new("Lily white")
        script.Parent.Parent.Light4.brickColor = BrickColor.new("Lily white")
        bool2 = true
    end
end)

script.Parent.Parent.KeycardReader2.touched:connect(function(touch)
    if touch.Name == "Handle" and clearance[touch.Parent.Name] and bool then
        bool = false
        script.Parent.AccessGranted:play()
        script.Parent.Parent.Light1.brickColor = BrickColor.new("Lime green")
        script.Parent.Parent.Light2.brickColor = BrickColor.new("Lime green")
        script.Parent.Parent.Light3.brickColor = BrickColor.new("Lime green")
        script.Parent.Parent.Light4.brickColor = BrickColor.new("Lime green")

        openDoor()
        wait(1)
        script.Parent.Parent.Light1.brickColor = BrickColor.new("Lily white")
        script.Parent.Parent.Light2.brickColor = BrickColor.new("Lily white")
        script.Parent.Parent.Light3.brickColor = BrickColor.new("Lily white")
        script.Parent.Parent.Light4.brickColor = BrickColor.new("Lily white")

        bool = true
    elseif touch.Name == "Handle" and not clearance[touch.Parent.Name] and bool2 then
        bool2 = false
        script.Parent.AccessDenied:play()
        script.Parent.Parent.Light1.brickColor = BrickColor.new("Really red")
        script.Parent.Parent.Light2.brickColor = BrickColor.new("Really red")
        script.Parent.Parent.Light3.brickColor = BrickColor.new("Really red")
        script.Parent.Parent.Light4.brickColor = BrickColor.new("Really red")
        wait(1)
        script.Parent.Parent.Light1.brickColor = BrickColor.new("Lily white")
        script.Parent.Parent.Light2.brickColor = BrickColor.new("Lily white")
        script.Parent.Parent.Light3.brickColor = BrickColor.new("Lily white")
        script.Parent.Parent.Light4.brickColor = BrickColor.new("Lily white")
        bool2 = true
    end
end)
0
try using more variables. starmaq 1290 — 5y

Answer this question