So let’s say I have a part that is tweened to move forward. After it’s done, I want to be able to bring it back to its original position at any time. The reverse parameter won’t work because it reverses it instantly after the tween, and I want to keep the part there for a while. Any solutions? I have 8 tweens that I need to reset, and I’m wondering if there is any way to do this without creating 8 more tweens that do the opposite.
Use a wait after the tween for however long you want it to stay and just tween it back.
For the 8 tween part, there is a way to do it, however, more context for that is needed.
Like, if the 8 parts were in a folder, you could use a for do loop to iterate through every part and just write one line of tween that goes for every iterated part.
Alright thanks, I will try that method.
It would look something like:
local TweenTime = 1; -- Set to how long you tween it
local WaitTime = 1; -- Set to how long you want to wait till it comes back
for _, obj in pairs(Folder:GetChildren()) do
local OriginalP = obj.Position
game:GetService("TweenService"):Create(obj, TweenInfo.new(TweenTime), {Position = Vector3.new(The new position)}):Play() -- Could use CFrame as well
delay(WaitTime, function()
game:GetService("TweenService"):Create(obj, TweenInfo.new(TweenTime), {Position = OriginalP}):Play() --
end)
end
Before reading my post;
THIS IS ASSUMING YOUR ONLY TWEENING 1 PART AND TRYING TO DO THE ORIGINAL POSITION THINGY:
anyway,
- before tweening, set a variable for the position
- then tween
use the variable you just made to set the position with part.Position = var
in your case, you might wanna use a table for the positions to be stored
so like {Part1Pos, Part2Pos, …} the list goes on and on and on
All you’d need to do is store the original positions of each of the 8 parts and then teleport them back when necessary.
local folder = workspace:WaitForChild("Folder")
local parts = folder:GetChildren()
local array = {}
for _, part in ipairs(parts) do
if part:IsA("BasePart") then
table.insert(array, part.Position)
--perform tween
end
end
task.wait(10) --whatever delay/cooldown here
for i, part in ipairs(parts) do --ipairs iterator so order is retained
part.Position = array[i]
end