Tween Module By Lazar

Here is a module on managing a tween,

utility: You can change the tweenInfo, and the properties

local TweenService = game:GetService("TweenService")

local TABLE_INSERT = table.insert

local Tween = {}
Tween.__index = Tween

function Tween.new(object, tweenInfo: TweenInfo, property: {[string]: any})
	assert(object and tweenInfo and property)
	
	local self = setmetatable({}, Tween)
	
	self.Object = object
	self.TweenInfo = tweenInfo
	self.Property = property
	self.Tween = nil
	
	return self
end

function Tween.Play(self: self, waitToCompleted: boolean?): ()
	if self.Tween then return end
	
	self.Tween = TweenService:Create(self.Object, self.TweenInfo, self.Property)
	
	self.Tween:Play()
	
	if waitToCompleted then
		self.Tween.Completed:Wait()
	end
	
	self.Tween = nil
end

function Tween.Stop(self: self): ()
	if not self.Tween then return end
	
	self.Tween:Stop()
	
	self.Tween = nil
end

function Tween.setTweenInfo(self: self, tweenInfo: TweenInfo): ()
	self.TweenInfo = tweenInfo
end

function Tween.setProperty(self: self, property: {[string]: any}): ()
	self.Property = property
end

export type self = typeof(Tween.new(...))

return Tween

no offense, but what’s the point of this? This feels like an over complicated version of Tween Service.

Also if I were you I would change the . to an : in the functions for the OOP

i use a “.” for get a self type, and yes i agree with you !