I am working on an animation for a model in my game. However it does not play and I am confused towards why.
Here are the lines responsible for the animation:
CV['TS']:Create(EP[1],CV['TI'],{CFrame=EP[1].CFrame + EP[1].CFrame.LookVector*c}):Play()
CV['TS']:Create(EP[2],CV['TI'],{CFrame=EP[2].CFrame + EP[2].CFrame.LookVector*c}):Play()
CV['TS']:Create(EP[3],CV['TI'],{CFrame=EP[3].CFrame + EP[3].CFrame.LookVector*c}):Play()
Entire script
local module = {}
local CV =
{
['EP'] = script.Parent.EffectParts,
['EffectParts'] =
{
script.Parent.EffectParts.n1,
script.Parent.EffectParts.n2,
script.Parent.EffectParts.n3
},
['TS'] = game:GetService("TweenService"),
['TI'] = TweenInfo.new(1,Enum.EasingStyle.Linear)
}
local Cashe =
{
['Active'] = false
}
local function Animate()
local AnimOrd = false
local EP = CV['EffectParts']
while Cashe['Active'] and task.wait(1) do
local c
if AnimOrd then c=1 else c=-1 end
CV['TS']:Create(EP[1],CV['TI'],{CFrame=EP[1].CFrame + EP[1].CFrame.LookVector*c}):Play()
CV['TS']:Create(EP[2],CV['TI'],{CFrame=EP[2].CFrame + EP[2].CFrame.LookVector*c}):Play()
CV['TS']:Create(EP[3],CV['TI'],{CFrame=EP[3].CFrame + EP[3].CFrame.LookVector*c}):Play()
AnimOrd = not AnimOrd
end
end
-- yes I did call on the function below
function module.OnStart()
Cashe['Active'] = true
coroutine.wrap(Animate)()
end
function module.OnInput(item:Part)
end
function module.OnEnd()
Cashe['Active'] = false
end
return module
I use arrays instead of multiple variables as each variable needs its own space in the computer’s memory, and having many values in one spot instead of them spread out in many other memory spots should me more effiecent.