Hello!
I would like to know how I can put a timeout in the time that the block is to return to where it was.
when the interpolation ends at the indicated position when I activated the option "Reverse" (true) It does not wait for 1 second and returns to the position it was in. How can I make him wait a few seconds and then go back to where he was?
Script:
local Part1, Part2 = script.Parent.PartA, script.Parent.PartB; local tweenInfo = TweenInfo.new( 2, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, true, 2 ) local a = TweenService:Create(Part1, tweenInfo, {Position = Vector3.new(81, 5, 197)}) local b = TweenService:Create(Part2, tweenInfo, {Position = Vector3.new(99, 5, 203)}) while wait()do a:Play() b:Play() end
If you want the part to go back after a certain timeout, you will need to split tween to 2 separate tweens:
local Part1, Part2 = script.Parent.PartA, script.Parent.PartB; local tweenTime = 2 local cooldown = 2 local tweenInfo = TweenInfo.new( tweenTime, Enum.EasingStyle.Linear ) local aStartingPosition = Part1.Position local bStartingPosition = Part2.Position local a = TweenService:Create(Part1, tweenInfo, {Position = Vector3.new(81, 5, 197)}) local aReverse = TweenService:Create(Part1, tweenInfo, {Position = aStartingPosition}) local b = TweenService:Create(Part2, tweenInfo, {Position = Vector3.new(99, 5, 203)}) local bReverse = TweenService:Create(Part2, tweenInfo, {Position = bStartingPosition}) while wait() do a:Play() b:Play() wait(tweenTime + cooldown) aReverse:Play() bReverse:Play() wait(tweenTime + cooldown) end
Just remeber that playing a tween does not yield the thread, so you need to add tween time to cooldown time, before playing reverse tween.