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

How do I add a delay between Tween Animation and Tween Reversal?

Asked by 4 years ago

So upon my quest to learn Lua I have decided to make a tweened sliding door. When I touch an invisible block the doors move as they should however I'd like them to stay open for a number of seconds before closing or reversing. Within my tween info I've set the 'TweenInfo.DelayTime to' to 7 seconds however this doesn't seem to be having an effect no matter what I change the value to. Below is my code:

local footPlate = game.Workspace.aff
local door1 = game.Workspace.door1
local door2 = game.Workspace.door2
local tweenService = game:GetService("TweenService")
local tweeningInfo = TweenInfo.new(

2, --length of tween
Enum.EasingStyle.Linear, --Easing style of tween
Enum.EasingDirection.Out, --Easing direction of tween
0, --Repeating number
true, --Reverse itself
7 --Time between tween and reversal?
)
local d1Position = door1.Position.X + 5.668
local d2Position = door2.Position.X - 5.668
local d1Y = door1.Position.Y
local d2Y = door2.Position.Y
local d1Z = door1.Position.Z
local d2Z = door2.Position.Z

local door1Pos = {Position = Vector3.new(d1Position,d1Y,d1Z)}
local door2Pos = {Position = Vector3.new(d2Position,d2Y,d2Z)}
local Tween1 = tweenService:Create(door1,tweeningInfo,door1Pos)
local Tween2 = tweenService:Create(door2,tweeningInfo,door2Pos)
footPlate.Touched:Connect(function(plr) --connects function to the action - runs moving doors script if footPlate is touched.
        if plr.Parent.Humanoid then
            Tween1:Play()
            Tween2:Play()
    end
end)

Answer this question