This code is meant to loop through the table of values and insert them into the tween function in order for the primary part of a model to be moved.
I had originally done the animation in Moon Animator but further realized I couldn’t export CFrame, thus decided to script it.
My line of code “tween(0.5, table.unpack(frames[i], i))” keeps resulting in the error “attempt to call a Instance value”. It runs through the tween function once, then results in this error. Any advice?
local TS = game:GetService("TweenService")
local primPart = game.Workspace.Airplane.planeDoor.anchor
wait(2)
local function tween(timeNum, p1,p2,p3, o1,o2,o3)
print("started")
local tweenInfo = TweenInfo.new(timeNum,
Enum.EasingStyle.Quad, -- change later
Enum.EasingDirection.Out, -- change maybe too
0,false,0)
local targetpos = CFrame.new(p1,p2,p3)
print(o1)
local degToRads1 = o1 * math.pi / 180
local degToRads2 = o2 * math.pi / 180
local degToRads3 = o3 * math.pi / 180
-- this is in RADIANS, not degrees!
local goal = { CFrame = targetpos * CFrame.fromEulerAnglesXYZ(degToRads1,degToRads2,degToRads3) }
tween = TS:Create(primPart, tweenInfo, goal)
tween:Play()
print("ran")
end
local frames = {
{69.801, 26.817, 48.355, -2.384, 178.09, 0.079,},
{70.3, 26.768, 49.526, 1.916, 36.578, 1.421},
{70.3, 26.768, 49.526, 1.31, 56.699, 1.993},
{70.3, 26.768, 49.526, 2.241, 20.016, 0.816},
{70.3, 26.768, 49.526, 2.376, 4.952, 0.206},
{70.3, 26.768, 49.526, 2.297, 15.632, 0.642},
{70.3, 26.768, 49.526, 2.376, 4.952, 0.206},
{70.3, 26.768, 49.526, 2.297, 15.632, 0.642},
{70.3, 26.768, 49.526, 2.376, 4.952, 0.206},
{70.3, 26.768, 49.526, 2.297, 15.632, 0.642},
{70.3, 26.768, 49.526, 2.376, 4.952, 0.206},
{70.3, 26.768, 49.526, 2.297, 15.632, 0.642},
{70.3, 26.768, 49.526, -55.732, 17.038, 7.241}
}
for i, v in pairs(frames) do
wait()
print(table.unpack(frames[i], i))
tween(0.5, table.unpack(frames[i], i))
end