Hello.
I am trying to create a script to tween a model to move left to right. Them model in workspace is called model2 and has 4 parts. The goal of the script is to loop through the children of the model and tween them all to a certain position indefinitely.
local part = game.Workspace.model2:GetChildren()
function tweenAll(part)
for i,v in ipairs(part) do
if v:IsA("BasePart") then
local TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(2,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,-1,true,0)
local tween = TweenService:Create(part,tweenInfo, {Position = Vector3.new(-1836.571, -22.494, 80)})
tween:Play()
end
end
end
tweenAll(part)
I have the Unable to cast method to Object error in the output, I don't know fi one of the parameters is wrong.

1 comment
Oh thank you so much! But another problem arose. The script itself works just dandy but I kind of expected the parts in the model to move in a straight line. Instead when I run the script, to get to the Position mentioned above, the parts in the model all move in a different way to get to the Position. Do you know how to make them all move in a straight line?