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

Im trying to make a animated door that opens when a key card touches it but it wont work?

Asked by 5 years ago
Edited 5 years ago

so im trying to make a door where when a key card touches the "KeyCardDectector", it checks if the key cards level is high enough and if so, will run multiple tweens... The problem is, it just doesn't work :/ i added checks to see where the problem was and it seems to be right when the local script starts~ here is the script:

local main = script.Parent.Parent.Parent
local light = script.Parent.Parent.ScanLight
local TweenService = game:GetService("TweenService")
local DL = main.DoorL
local DR = main.DoorR
local DLbars = main.DoorLBars
local DRbars = main.DoorRBars
local DLcover = main.DoorLCover
local DRcover = main.DoorRCover
local tweenInfo = TweenInfo.new(
    1,
    Enum.EasingStyle.Sine,
    Enum.EasingDirection.Out,
    0,
    false,
    0
)

local DoorROpen = {CFrame = CFrame.new(7, 3.5, 6.7)}
local DoorRClose = {CFrame = CFrame.new(7, 3.5, 3.5)}

local DoorLOpen = {CFrame = CFrame.new(7, 3.5, -1.8)}
local DoorLClose = {CFrame = CFrame.new(7, 3.5, 1.6)}

local DoorRCoverOpen = {CFrame = CFrame.new(6.95, 3.5, 6.7)}
local DoorRCoverClose = {CFrame = CFrame.new(6.95, 3.5, 3.5)}

local DoorLCoverOpen = {CFrame = CFrame.new(6.95, 3.5, -1.7)}
local DoorLCoverClose = {CFrame = CFrame.new(6.95, 3.5, 1.5)}

local DoorRBarsOpen = {CFrame = CFrame.new(6.95, 3.5, 6.5)}
local DoorRBarsClose = {CFrame = CFrame.new(6.95, 3.5, 3.5)}

local DoorLBarsOpen = {CFrame = CFrame.new(6.95, 3.5, -1.5)}
local DoorLBarsClose = {CFrame = CFrame.new(6.95, 3.5, 1.5)}
--------------------------------------------------------------
local DoorRtween1 = TweenService:Create(DR,tweenInfo,DoorROpen)
local DoorRtween2 = TweenService:Create(DR,tweenInfo,DoorRClose)

local DoorLtween1 = TweenService:Create(DL,tweenInfo,DoorLOpen)
local DoorLtween2 = TweenService:Create(DL,tweenInfo,DoorLClose)

local DoorRBarstween1 = TweenService:Create(DRbars,tweenInfo,DoorRBarsOpen)
local DoorRBarstween2 = TweenService:Create(DRbars,tweenInfo,DoorRBarsClose)

local DoorLBarstween1 = TweenService:Create(DLbars,tweenInfo,DoorLBarsOpen)
local DoorLBarstween2 = TweenService:Create(DLbars,tweenInfo,DoorLBarsClose)

local DoorRCovertween1 = TweenService:Create(DRcover,tweenInfo,DoorRCoverOpen)
local DoorRCovertween2 = TweenService:Create(DRcover,tweenInfo,DoorRCoverClose)

local DoorLCovertween1 = TweenService:Create(DLcover,tweenInfo,DoorLCoverOpen)
local DoorLCovertween2 = TweenService:Create(DLcover,tweenInfo,DoorLCoverClose)

script.Parent.Touched:Connect(function(hit)
    if main.DoorOpenCheck == false then
        main.DoorOpenCheck = true
        if hit.Name == "KeyCard" then
            print("Check 1 complete")
            if hit.Rank.Value >= main.Rank.Value then
                print("Check 2 complete")
                DoorRBarstween1:Play()
                DoorLBarstween1:Play()
                wait(1)
                DoorRCovertween1:Play()
                DoorLCovertween1:Play()
                DoorRtween1:Play()
                DoorLtween1:Play()
                wait(4)
                DoorRBarstween2:Play()
                DoorLBarstween2:Play()
                DoorRCovertween2:Play()
                DoorLCovertween2:Play()
                DoorRtween2:Play()
                DoorLtween2:Play()
            end
        end
        main.DoorOpenCheck = false
    end
end)

Help would be much appreciated, thanks!

0
You don’t need to make it FE compatible. It already is. Just handle everything on the server. User#19524 175 — 5y
0
I think you overcomplicated things, by like alot. You could run a tocuhed function in the detector and if it hits any part of the card, you use CFrame to open it. Different levels could be bool values inside of the card that check level. Maybe a number value for each level like 1-4 1 being lowest and 4 highest. joshthegamer456 93 — 5y
0
^ User#19524 175 — 5y
0
I did what you send, but it still wont work.. ill update the post cruizer_snowman 117 — 5y
0
i fixed it, just a problem with me not knowing what the parent of a part is xD cruizer_snowman 117 — 5y

Answer this question