My tweenservice isn't moving the model

Hello! I need a small help.

When I’m trying to move with a tweenservice a model (welded) it doesn’t work:

local tweenservice = game:GetService("TweenService")
	local primary = script.Parent.Parent.Parent.chest
	local tweeninfo = TweenInfo.new(3)
	local target = {CFrame = primary.CFrame + Vector3.new(0,0.907,0)}
        local tween = tweenservice:Create(primary,tweeninfo,target)

	tween:Play()

The error is: CFrame is not a valid member of Model "Workspace.Oil.Base.number1.chest"

Thank you, hope someone can help! :smiley:

Probably I wrong with cframe. But I’m not sure.

is primary a part or a model?

it is a model, with parts inside.

Models don’t have CFrame properties, if you want to move a model, you’d have to use :MoveTo() or :PivotTo(), or you could set a PrimaryPart, weld everything to that part, unanchor everything except that part, then tween the part somewhere.

1 Like

To move a model you have to use model:PivotTo(), and you can’t tween the model itself like that. To tween a model you would have to set its PrimaryPart to one of the parts within the model, make sure all the other parts are not anchored and welded to the primary part, then you can tween model.PrimaryPart’s CFrame and it should move the entire model. The other way would be to not use TweenService and instead lerp the model which is a little more complicated:

local run = game:GetService("RunService")

local cumulative = 0
local final = 5 --how long in seconds it will take

local startpoint = model:GetPivot()
local endpoint = --cframe of where you want it to move

while cumulative < final do
	cumulative += run.Heartbeat:Wait()
	model:PivotTo(startpoint:Lerp(endpoint,cumulative/final))
end
2 Likes

Thank you guys!
It works.
Sadly I can’t give two solved, but thank you QTX_isle and mile.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.