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

Tweening // Double-Door Script Freaking Out?

Asked by 6 years ago

So, this is the script we're dealing with:

-- VARIABLES --
TweenService = game:GetService("TweenService")

Group = script.Parent
LeftDoor = Group.Door["Left Door"].Door
LeftDoorWindow = Group.Door["Left Door"]["Door Window"]
RightDoor = Group.Door["Right Door"].Door
RightDoorWindow = Group.Door["Left Door"]["Door Window"]
KeycardSlot = Group["Door Frame"]["Keycard Scanner"]["Keycard Slot"]
KeycardSlotIndicator = Group["Door Frame"]["Keycard Scanner"]["Keycard Slot Indicator"]
Orientation = LeftDoor.Orientation

Config = Group.Configuration
Direction = Config.Direction.Value
SecurityLevel = Config.SecurityLevel.Value
OpeningDuration = Config.OpeningDuration.Value
ClosingDuration = Config.ClosingDuration.Value
OpenDuration = Config.OpenDuration.Value
CurrentlyActive = Config.CurrentlyActive.Value
Locked = Config.Locked.Value

Assets = Group.Assets
DoorOpeningAudio = Assets.DoorOpening
DoorClosingAudio = Assets.DoorClosing
KeycardAcceptAudio = Assets.KeycardAccept
KeycardDenyAudio = Assets.KeycardDeny

DoorOpenInformation = TweenInfo.new(OpeningDuration, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)
DoorCloseInformation = TweenInfo.new(ClosingDuration,Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)

LeftDoorOpenXP = {CFrame = CFrame.new(LeftDoor.Position.X + 3.75, LeftDoor.Position.Y, LeftDoor.Position.Z)}
LeftDoorOpenXM = {CFrame = CFrame.new(LeftDoor.Position.X - 3.75, LeftDoor.Position.Y, LeftDoor.Position.Z)}
LeftDoorOpenZP = {CFrame = CFrame.new(LeftDoor.Position.X, LeftDoor.Position.Y, LeftDoor.Position.Z + 3.75)}
LeftDoorOpenZM = {CFrame = CFrame.new(LeftDoor.Position.X, LeftDoor.Position.Y, LeftDoor.Position.Z - 3.75)}
LeftWindowOpenXP = {CFrame = CFrame.new(LeftDoorWindow.Position.X + 3.75, LeftDoorWindow.Position.Y, LeftDoorWindow.Position.Z)}
LeftWindowOpenXM = {CFrame = CFrame.new(LeftDoorWindow.Position.X - 3.75, LeftDoorWindow.Position.Y, LeftDoorWindow.Position.Z)}
LeftWindowOpenZP = {CFrame = CFrame.new(LeftDoorWindow.Position.X, LeftDoorWindow.Position.Y, LeftDoorWindow.Position.Z + 3.75)}
LeftWindowOpenZM = {CFrame = CFrame.new(LeftDoorWindow.Position.X, LeftDoorWindow.Position.Y, LeftDoorWindow.Position.Z - 3.75)}
LeftDoorClosed = {CFrame = CFrame.new(LeftDoor.Position.X, LeftDoor.Position.Y, LeftDoor.Position.Z)}
LeftWindowClosed = {CFrame = CFrame.new(LeftDoorWindow.Position.X, LeftDoorWindow.Position.Y, LeftDoorWindow.Position.Z)}

RightDoorOpenXP = {CFrame = CFrame.new(RightDoor.Position.X + 3.75, RightDoor.Position.Y, RightDoor.Position.Z)}
RightDoorOpenXM = {CFrame = CFrame.new(RightDoor.Position.X - 3.75, RightDoor.Position.Y, RightDoor.Position.Z)}
RightDoorOpenZP = {CFrame = CFrame.new(RightDoor.Position.X, RightDoor.Position.Y, RightDoor.Position.Z + 3.75)}
RightDoorOpenZM = {CFrame = CFrame.new(RightDoor.Position.X, RightDoor.Position.Y, RightDoor.Position.Z - 3.75)}
RightWindowOpenXP = {CFrame = CFrame.new(RightDoorWindow.Position.X + 3.75, RightDoorWindow.Position.Y, RightDoorWindow.Position.Z)}
RightWindowOpenXM = {CFrame = CFrame.new(RightDoorWindow.Position.X - 3.75, RightDoorWindow.Position.Y, RightDoorWindow.Position.Z)}
RightWindowOpenZP = {CFrame = CFrame.new(RightDoorWindow.Position.X, RightDoorWindow.Position.Y, RightDoorWindow.Position.Z + 3.75)}
RightWindowOpenZM = {CFrame = CFrame.new(RightDoorWindow.Position.X, RightDoorWindow.Position.Y, RightDoorWindow.Position.Z - 3.75)}
RightDoorClosed = {CFrame = CFrame.new(RightDoor.Position.X, RightDoor.Position.Y, RightDoor.Position.Z)}
RightWindowClosed = {CFrame = CFrame.new(RightDoorWindow.Position.X, RightDoorWindow.Position.Y, RightDoorWindow.Position.Z)}



-- FUNCTIONS --
function OpenDoor()
    print("Function 'OpenDoor' has been called.")
    if LeftDoor.Size.X > LeftDoor.Size.Z and LeftDoor.Position.X > RightDoor.Position.X then
        local TweenLeftDoor = TweenService:Create(LeftDoor, DoorOpenInformation, LeftDoorOpenXP)
        local TweenLeftWindow = TweenService:Create(LeftDoorWindow, DoorOpenInformation, LeftWindowOpenXP)
        local TweenRightDoor = TweenService:Create(RightDoor, DoorOpenInformation, RightDoorOpenXM)
        local TweenLeftDoor = TweenService:Create(RightDoorWindow, DoorOpenInformation, RightWindowOpenXM)
        TweenLeftDoor:Play()
        TweenLeftWindow:Play()
        TweenRightDoor:Play()
        TweenRightDoor:Play()
        DoorOpeningAudio:Play()
    elseif LeftDoor.Size.X > LeftDoor.Size.Z and LeftDoor.Position.X < RightDoor.Position.X then -- THIS IS THE SECTION THE CODE RUNS
        local TweenLeftDoor = TweenService:Create(LeftDoor, DoorOpenInformation, LeftDoorOpenXM)
        local TweenLeftWindow = TweenService:Create(LeftDoorWindow, DoorOpenInformation, LeftWindowOpenXM)
        local TweenRightDoor = TweenService:Create(RightDoor, DoorOpenInformation, RightDoorOpenXP)
        local TweenLeftDoor = TweenService:Create(RightDoorWindow, DoorOpenInformation, RightWindowOpenXP)
        TweenLeftDoor:Play()
        TweenLeftWindow:Play()
        TweenRightDoor:Play()
        TweenRightDoor:Play()
        DoorOpeningAudio:Play()
    elseif LeftDoor.Size.X < LeftDoor.Size.Z and LeftDoor.Position.X > RightDoor.Position.X then
        local TweenLeftDoor = TweenService:Create(LeftDoor, DoorOpenInformation, LeftDoorOpenZP)
        local TweenLeftWindow = TweenService:Create(LeftDoorWindow, DoorOpenInformation, LeftWindowOpenZP)
        local TweenRightDoor = TweenService:Create(RightDoor, DoorOpenInformation, RightDoorOpenZM)
        local TweenLeftDoor = TweenService:Create(RightDoorWindow, DoorOpenInformation, RightWindowOpenZM)
        TweenLeftDoor:Play()
        TweenLeftWindow:Play()
        TweenRightDoor:Play()
        TweenRightDoor:Play()
        DoorOpeningAudio:Play()
    elseif LeftDoor.Size.X < LeftDoor.Size.Z and LeftDoor.Position.X < RightDoor.Position.X then
        local TweenLeftDoor = TweenService:Create(LeftDoor, DoorOpenInformation, LeftDoorOpenZM)
        local TweenLeftWindow = TweenService:Create(LeftDoorWindow, DoorOpenInformation, LeftWindowOpenZM)
        local TweenRightDoor = TweenService:Create(RightDoor, DoorOpenInformation, RightDoorOpenZP)
        local TweenLeftDoor = TweenService:Create(RightDoorWindow, DoorOpenInformation, RightWindowOpenZP)
        TweenLeftDoor:Play()
        TweenLeftWindow:Play()
        TweenRightDoor:Play()
        TweenRightDoor:Play()
        DoorOpeningAudio:Play()
    else
        print("There is an issue with the SCP containment door. Relationship operations have failed.")
    end
end

function CloseDoor()
    local TweenLeftDoor = TweenService:Create(LeftDoor, DoorCloseInformation, LeftDoorClosed)
    local TweenLeftWindow = TweenService:Create(LeftDoorWindow, DoorCloseInformation, LeftWindowClosed)
    local TweenRightDoor = TweenService:Create(RightDoor, DoorCloseInformation, RightDoorClosed)
    local TweenLeftWindow = TweenService:Create(RightDoorWindow, DoorCloseInformation, RightWindowClosed)
    TweenLeftDoor:Play()
    TweenLeftWindow:Play()
    TweenRightDoor:Play()
    TweenRightDoor:Play()
    DoorClosingAudio:Play()
end

-- EVENTS --
KeycardSlot.Touched:connect(function(Part)
    if Part.Parent.Name == "Level V Keycard" then
        print("A Level V keycard was inserted into the keycard slot")
        if not CurrentlyActive and not Locked then
            CurrentlyActive = true
            KeycardAcceptAudio:Play()
            OpenDoor()
            wait(OpeningDuration + OpenDuration)
            CloseDoor()
            wait(ClosingDuration + 2)
            CurrentlyActive = false
        end
    end
end)

-- Created by CyroStorms

The issue is that nothing happens to any of the doors apart from the right door, which literally flips out. I can fix that, though.

So the real issue here is why my Tweens aren't playing. Can anyone lend me a hand here? I'll leave the game open for you guys to see what's going wrong: https://www.roblox.com/games/1142382109/CyroStorms-SCP-Site-In-Dev-Testing

0
Seriously? Not describing your code?? hiimgoodpack 2009 — 6y
0
I already did, no? It's a double door tweening script that "literally flips out". "the real issue here is why my Tweens aren't playing." CyroStorms 4 — 6y
0
You still have not descrrbed the parts. hiimgoodpack 2009 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

When tweening, Make the parts you want to move anchored, and not cancollide, if they are backing into something.

Ad

Answer this question