Hello! I am currently making a script that tweens every part with the tag of “Part” using OOP.
My problem is that my tween function is saying:
unable to cast to dictionary
Here is my code:
local tweenService = game:GetService("TweenService")
local part = {}
part.__index = part
part.tweenTime = 2
function part:new(model)
local newPart = setmetatable({}, self)
newPart.__index = newPart
newPart.Model = model
return newPart
end
function part:tweenSize(properties)
local tween = tweenService:Create(
self.Model,
TweenInfo.new(self.tweenTime, Enum.EasingStyle.Elastic, Enum.EasingDirection.In, -1, true, 0.5),
properties
)
return tween
end
function part:startTween()
local properties = self.Model.Size * Vector3.new(20, 20, 20)
local tween = self:tweenSize(properties)
tween:Play()
end
return part
Tagged code:
local collectionService = game:GetService("CollectionService")
local tagged = collectionService:GetTagged("Part")
local partModule = require(game:GetService("ServerScriptService")
for i, part in pairs(tagged) do
local newPart = partModule:new(part)
newPart:startTween()
end
If you can help, please reply ![]()