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

how to put a cooldown on Tween?

Asked by 5 years ago
Edited 5 years ago

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:

01local Part1, Part2 = script.Parent.PartA, script.Parent.PartB;
02 
03local tweenInfo = TweenInfo.new(
04 
05    2,
06    Enum.EasingStyle.Linear,
07    Enum.EasingDirection.Out,
08    0,
09    true,
10    2
11)
12 
13 
14 
15local a = TweenService:Create(Part1, tweenInfo, {Position = Vector3.new(81, 5, 197)})
View all 22 lines...
0
use a wait(1) greatneil80 2647 — 5y

1 answer

Log in to vote
1
Answered by
sleazel 1287 Moderation Voter
5 years ago
Edited 5 years ago

If you want the part to go back after a certain timeout, you will need to split tween to 2 separate tweens:

01local Part1, Part2 = script.Parent.PartA, script.Parent.PartB;
02 
03local tweenTime = 2
04local cooldown = 2
05 
06local tweenInfo = TweenInfo.new(
07 
08    tweenTime,
09    Enum.EasingStyle.Linear
10 
11)
12 
13 
14local aStartingPosition = Part1.Position
15local bStartingPosition = Part2.Position
View all 33 lines...

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.

Ad

Answer this question