TweenService animation not playing

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.

It should be
{CFrame=EP[1].CFrame * EP[1].CFrame.LookVector*c}

1 Like

Yes, this is correct. However, I’d say you very rarely need to worry about this. I’d say you are overcomplicating things. Also, keep in mind.

When handling information you need to remember one core principle. Using less memory → more calculations and vice verca.

  1. Have you tried doing the animations without using the table (CV)?
  2. Have you made sure module.OnStart() is actually run? (ex: a print is executed)
  3. Have you made sure the coroutine is run as intended? (Apart from the Tween)

Also, I believe it is spelled “Cache”.

1 Like

CFrame.LookVector is a Vector3 value and not a CFrame or CFrame.Angles value. And like all Vectors, it is added to the CFrame.

Unless there is something I am mis-understanding, my calculation should be correct.