OOP Animation Module

I am trying to learn Object-Oriented Programming. So the first project I wanted to do with it is an Animation Module. In which you can give out arguments and start it with its own function! Pretty cool but I can’t wrap my head around this Output so I don’t know how to fix this problem.

The Module,

local Animation = {}
Animation.__index = Animation

function Animation.New(obj, timer, reverse, TweenProperties)
    return setmetatable({
     track = game:GetService("TweenService"):Create(obj, TweenInfo.new() , 0, reverse, 0,TweenProperties)} -- Output says this line has a problem!
    ,Animation)
end

function Animation:Start()
    self.track:Play()
end

return Animation

When I make a script like this,

local Animator = require(script.Parent.Animator)
local Hinge = workspace.Plot_a.Home.Door:WaitForChild("Hinge")
local DoorAnim = Animator.New(Hinge, 0.25, true, {CFrame = Hinge.CFrame*CFrame.Angles(0,-90,0)})  -- Output says this line has a problem!

DoorAnim:Start()

The output says this,

Unable to cast to Dictionary

1 Like

you are passing the timer and reverse values but are not even using them?
and tweenservice is supposed to take 3 parameters,

TweenService:Create(part, tweenInfo, goal)

and the settings of tweenInfo are

2 Likes

Thanks a lot for the in depth info… I got it working because apparently I messed up my params really badly and didn’t noticed!

1 Like