So right now I’m looping through a table of parts in my workspace, I want to similtaenously do a tween where it goes up and another that goes down, Like a hovering effect.
Right now the problem is it only animates the first tween, if I use tween.Completed, it yields my for i,v pairs loop and it doesn’t make the parts animate at the same time.
I have tried to put the tweening into diffrent functions and calling them from the i,v loop but still same problem
--Services--
local tweenService = game:GetService("TweenService")
--Tables--
local function getParts()
local allParts = {}
local folder = game.Workspace:WaitForChild("Folder")
for i,v in pairs(folder:GetChildren()) do
table.insert(allParts, v)
end
return allParts
end
print(getParts()[1].Name)
--Vairables--
local part = getParts()
local Time = 5
local tweenInfo = TweenInfo.new(Time, Enum.EasingStyle.Linear, Enum.EasingDirection.In, -1 )
local function up(part)
local newPos = CFrame.new(0, 1, 0)
local tween = tweenService:Create(part, tweenInfo, {CFrame = part.CFrame * newPos})
tween:Play()
end
local function down(part)
local endPos = CFrame.new(0, -1, 0)
local tween2 = tweenService:Create(part, tweenInfo, {CFrame = part.CFrame * endPos})
tween2:Play()
end
local function animations(part, Time, Dist, bool)
--Variables--
--local tweenInfo = TweenInfo.new(Time, Enum.EasingStyle.Linear, Enum.EasingDirection.In, -1 )
for i,v in pairs(part) do
down(v)
up(v)
--local newPos = CFrame.new(0, 1, 0)
--local endPos = CFrame.new(0, -1, 0)
--local tween = tweenService:Create(v, tweenInfo, {CFrame = v.CFrame * endPos})
--local tween2 = tweenService:Create(v, tweenInfo, {CFrame = v.CFrame * newPos})
--tween:Play()
--tween2:Play()
end
end
animations(part, Time)