Happy St. Patrick's Day!
I have a solution for you!
Inside the 'Create' table, you did part.Position, instead of part.Position, just do Position, and replace == with =.
e.g:
1 | local create = { Position = Vector 3. new(- 194.115 , 34.227 , - 1.536 ) } |
I have decided to expand upon your script.
I have a new-and-improved version!
01 | local reachedGoal = false |
02 | local OGPos = script.Parent.Position |
03 | local GoalPos = workspace.Part 2. Position |
04 | local Tween = game:GetService( "TweenService" ) |
05 | local part = script.Parent |
07 | local info = TweenInfo.new( infotime, Enum.EasingStyle.Elastic, Enum.EasingDirection.Out, 0 , true , 0 ) |
10 | if reachedGoal = = false then |
12 | local info = TweenInfo.new( 5 , Enum.EasingStyle.Elastic, Enum.EasingDirection.Out, 0 , true , 0 ) |
15 | local tweencreate = Tween:Create(part,info, { Position = GoalPos } ) |
19 | tweencreate.Completed:Connect( function () |
21 | print ( "Reached Second Position." ) |
27 | local tweencreate = Tween:Create(part,info, { Position = OGPos } ) |
31 | tweencreate.Completed:Connect( function () |
33 | print ( "Reached First Position." ) |
LOTS to explain here, so time to begin.
I added a variable called 'reachedGoal' which is used later on.
I added 2 position variables, our original position and our Part2 position.
Then some extra variables, then a loop.
This loop checks if reachedGoal is either true or false every second.
If reachedGoal is false, then we continue.
We get the info, then create the tween.
It gets the part, info, and the Position.
Since reachedGoal is false, we go to GoalPos (aka Part2's position).
We paly the animation, and start a Completed function.
The Completed function fires when the Tween is, well, completed!
It switches reachedGoal to true, and then it fires the opposite code.
It's basically the same code, just with some differences.
Instead of GoalPos, it's OGPos.
Also, after both these functions, theres a wait().
This makes it wait the amount of time the tween is with the added 2.5 wait.
That's basically it, thanks for reading, and if you found this helpful, make sure you set this as 'solved'!