Tweening a model to go up and down

I am trying to make a script that will elevate a model using TweenService.

Error: ServerScriptService.Script:11: attempt to call a CFrame value

Script:

local endCFrame = CFrame.new(-708.97, 47.097, 58.504)

local TweenService = game:GetService("TweenService")

local model = workspace.StageEssentials.StageLift
local modelroot = model.PrimaryPart

local twenInfo = TweenInfo.new(5) 

local tween = TweenService:Create(modelroot, TweenInfo, {CFrame = modelroot.CFrame(endCFrame)})

wait(50)
tween:Play()

All support is appreciated!

3 Likes

Unfortunately I don’t really know, but good luck!

Maybe I did it in an un-functioning way - would you do it any other way?

I’d say check out youtube, but the website doesn’t give you direct answers, I know how to ui tween only.

I’m just testing stuff, but would this work?

local endCFrame = CFrame.new(-708.97, 47.097, 58.504)

local TweenService = game:GetService("TweenService")

local model = workspace.StageEssentials.StageLift
local modelroot = model.PrimaryPart

local twenInfo = TweenInfo.new(5) 

local tween = TweenService:Create(modelroot, TweenInfo, {CFrame = endCFrame})

wait(50)
tween:Play()
1 Like

Just tried this, and a new error appeared, however, the other one disappeared.
Unable to cast Dictionary to TweenInfo

1 Like

Sorry about that, my mistake

local endCFrame = CFrame.new(-708.97, 47.097, 58.504)

local TweenService = game:GetService("TweenService")

local model = workspace.StageEssentials.StageLift
local modelroot = model.PrimaryPart

local twenInfo = TweenInfo.new(5) 

local tween = TweenService:Create(modelroot, twenInfo , {CFrame = endCFrame})

wait(50)
tween:Play()

This did work, however, it didn’t tween the whole model with it. Just the primary part.

One way you could do it is to weld all the parts in the model to the to the primarypart and then just unanchor them

Would this work to quickly weld everything if I put it in the command bar?

local model = workspace.StageEssentials.StageLift
local ppart = model.PrimaryPart

for i, v in pairs(model:GetChildren()) do
	if v:IsA("BasePart") and (v ~= ppart) then
		local weld = Instance.new("WeldConstraint", v)
		weld.Part0 = v 
		weld.Part1 = ppart
	end
end

You can just Select all the parts and click the weld option under the model tab

I’m pretty sure you’re going to have to tween every part/mesh in the model manually.

Even after welding every part in the model (except the primary part), it still isn’t working.

Wouldn’t that be really messy, and could cause potential issues?

1 Like

Did you unanchor all the parts in the model except for the primarypart?

My mistake, I didn’t. However, I just tested and it did work although the parts are all in incorrect places and some of them don’t even appear to be visible (Hidden in the primary part). Is there anyway to fix this?

Ah, well do you have the moon animator plugin?

Yes, I do. Why, would that fix it?

It has the easy weld button, it might fix your welding problems so click on it and select parts then click the primarypart first then the rest of the parts, then click join in place and make sure that animateble is off

indeed it would, I’m pretty sure its the only way tho