Model Won't Tween

Not much to say here, I’m trying to tween a model but it won’t work. All parts have a WeldConstraint attached to the PrimaryPart, all parts have anchored turned off, and I was using CFrame to move the part. (As using Vector3 will offset the WeldConstraint, and then only the PrimaryPart will move) However, it’s still not working.
You see, whenever I run, It shows no errors, but the PrimaryPart won’t move.

The code I used
local Part = game.Workspace.Circle.PrimaryPart
	
	TweenService = game:GetService("TweenService")
	TweenGoal = {CFrame = CFrame.new(0,10,0)}
 	TweeningInfo = TweenInfo.new(
		2,
		Enum.EasingStyle.Quad,
		Enum.EasingDirection.InOut,
		-1,
		true,
		0
		)

local TweenPart = TweenService:Create(Part, TweeningInfo,TweenGoal)
	

local CircleCenter = game.Workspace.Circle.CenterPart

local Circle = game.Workspace.Circle

TweenPart:Play()

How do I get it to move, while also getting the rest of the model to move with it? Any help is appreatiated.

1 Like

What type of script is it and where is it located?

1 Like

It’s just a regular script, and it is located in the workspace.

This script worked fine for me. Make sure to put it in a Script and not LocalScript if you haven’t.

Well, keep in mind I used a model. There aren’t any errors popping up, but the block just straight up won’t move.

Hi, please start of with making sure that your part has spawned in before running the code. Also I would suggest removing the Part-variable, put the Circle & CircleCenter variable at the top, and tween the Circle.PrimaryPart (since this is the same as Part)

local TweenService = game:GetService("TweenService")

local Circle = workspace:WaitForChild("Circle")
local CircleCenter = Circle:WaitForChild("CenterPart")

local Info = TweenInfo.new(2,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut,-1,true,0)
local Goal = {CFrame = Circle.PrimaryPart.CFrame + Vector3.new(0,10,0)}

local Tween = TweenService:Create(Circle.PrimaryPart,Info,Goal)
Tween:Play()

Be aware that this will only tween the PrimaryPart, and not the whole model. Please let me know if you wish to tween the whole model.

1 Like

Be aware that this will only tween the PrimaryPart, and not the whole model. Please let me know if you wish to tween the whole model.

The goal I had in mind was to tween the whole model by tweening the PrimaryPart. How can I tween the whole model?

I just noticed at the end of the thread, that you wish to move the whole model. Here’s the process:

		local Circle = workspace:WaitForChild("Circle") -- We wait for our Circle to spawn in
		
		local CF_v = Instance.new("CFrameValue") --We create a new CFrame value, we tween this value instead of the primarypart, to move the model everytime this value changes.
		CF_v.Changed:Connect(function(V) -- We set up the function that moves our model everytime our newly created CFrame value changes.
			Circle:PivotTo(V) -- Move the model
		end)
		
		CF_v.Value = Circle:GetPivot() -- We initializing/setting the start point of our newly created CFrame value, to be in the location of the model's PivotPoint
		
		local Info = TweenInfo.new(2,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut,-1,true,0)
		local NewCFrame = Circle.PrimaryPart.CFrame + Vector3.new(0,10,0)  -- Determine our Goal
		local Tween = TweenService:Create(CF_v,Info,{Value = NewCFrame}) -- Set up the tween
		Tween:Play() -- Play the tween

Hope this helped you out!

Edit: While writing this, you could in theory just make the .Changed event for the primarypart, and prevent creating a new CFrame value, but go with the approach you prefer

1 Like

Wait, I just tried this out and apparently the entire model moves, without needing to do anything extra. I think it’s because I used a WeldConstraint to weld each part to the PrimaryPart, and then unanchored everything.

Edit: Thank you though, this helped a lot :smiley:

My approach is for models that is fully anchored

I see. One last thing, how would you rotate the model while it’s tweening? Would you use the tween to rotate, or can you rotate and tween at the same time?

You would do something like this:

local Goal = (Circle.PrimaryPart.CFrame + Vector3.new(0,10,0)) * CFrame.Angles(math.rad(90),0,0)

I rarely use the CFrame.Angles, so there might be a typo.

Well, the problem here is that I used a reverse loop to make the model go up, and then down, and I want the model to spin in the same direction. Would I have to make two different tweens, one going up, and one going down?

Yes you would use two tweens there, and then make a infinite while loop in a spawn function.

spawn(function()

	-- Keep tweeninfo and goals out of the while loop, so the script only needs to read them once.
	while true do
		--TweenOne
		TweenOne.Completed:Wait()
		--TweenTwo
		TweenTwo.Completed:Wait()
	end
end)

Well, now I’ve run into another obstacle. Whenever I try and rotate it, it rotates, but then it kinda just stops.

local TweenService = game:GetService("TweenService")

local Circle = workspace:WaitForChild("Circle")

local Info = TweenInfo.new(2,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut,0, false,0)
local TweenUpGoal = {CFrame = Circle.PrimaryPart.CFrame * CFrame.new(0,10,0) * CFrame.Angles(0,math.rad(10),0)}
local TweenDownGoal = {CFrame = Circle.PrimaryPart.CFrame * CFrame.Angles(0,math.rad(10),0)}


local UpTween = TweenService:Create(Circle.PrimaryPart,Info,TweenUpGoal)
local DownTween = TweenService:Create(Circle.PrimaryPart,Info,TweenDownGoal)

wait(3)

while task.wait() do
	UpTween:Play()
	wait(2)
	DownTween:Play()
	wait(2)
end

I think this might be because of the fact that it only rotates to a certain point and stops, but I don’t know how to keep making it rotate.

Hi!

With this low amount of rotation/movement you should keep your goals inside the while loop, and update the goals after each tween. Also use .Completed:Wait() rather than using waits.

while true do -- No need for task.wait() here, since we're having waits below
local TweenUpGoal = {CFrame = Circle.PrimaryPart.CFrame * CFrame.new(0,10,0) * CFrame.Angles(0,math.rad(10),0)}
local UpTween = TweenService:Create(Circle.PrimaryPart,Info,TweenUpGoal)
	UpTween:Play()
	UpTween.Completed:Wait()
local TweenDownGoal = {CFrame = Circle.PrimaryPart.CFrame * CFrame.Angles(0,math.rad(10),0)}
local DownTween = TweenService:Create(Circle.PrimaryPart,Info,TweenDownGoal)
	DownTween:Play()
	DownTween.Completed:Wait()
end
1 Like

Ooh wait, ran into another problem. You see with Tweening, I’m using an easing style for it going up and down, but since I’m also using the tween to rotate, the easing style still applies.
What I’m saying is, in terms of the part going up and down, I want to use a Quad easing style. But in terms of rotation, I want to use a linear easing style.

Am I being too picky? I’m worried that what I’m trying to do is too complicated.

You’re not too picky, you just need to approach it right then.

I would suggest making 2 Models, A outer-model and a inner-model.

Then you tween the inner-model with the up & down, and tween the outer-model with the rotation.

I cannot guarantee that it is the best approach, but it’s simple and it does the job.

What do you mean an Outer and Inner model? Do you want me to put a model in a model?

Yep that is exactly what I am suggesting.