How would I tween BOTH position and rotation of a model

PLEASE READ:
I am trying to tween the position AND rotation of a model. This is multiple parts welded together connected with a primary part.

part of my issue is the tween must move up and down slowly with the easing style “Sine”
and the tween must rotate 360 degrees around with the easing style “Linear”

I’m doing something wrong with my current script (see below) as it only applies the tween to the primary part. No other parts in the model move with it.

-All of the parts are welded together
-The model has a primary part

local maxwell = script.Parent.PrimaryPart
local maxwellPos = maxwell.Position
local maxwellrot = maxwell.Rotation

local tweenservice = game:GetService("TweenService")

local info1 = TweenInfo.new(
	0.8,
	Enum.EasingStyle.Sine,
	Enum.EasingDirection.InOut,
	-1,
	true
)

local info2 = TweenInfo.new(
	2.5,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.InOut,
	-1,
	false
)

local newTween = tweenservice:Create(maxwell, info1,{ Position = maxwellPos + Vector3.new(0, 1, 0)})
local newTween2 = tweenservice:Create(maxwell, info2,{ Rotation = maxwellrot + Vector3.new(0, 360, 0)})
newTween:Play()
newTween2:Play()

Thank you, I am not good at scripting, and I am getting desperate

maxwell dance.rbxl (89.9 KB)
– the project file if needed

You should use CFrame instead of Position

I tested the game and it seemed to work fine? all parts in the model moved (the whiskers and the cat) and the rotation and movement played at the same time? What am I missing?

You need to use CFrame instead of Position and Rotation.

Position and Rotation only move a single object, the selected one, even if other parts are weld to it.

CFrame move a group of objects, so it move the selected part and all the parts welded to it.

tweenservice:Create(maxwell, info1, {CFrame = maxwell.CFrame * CFrame.new(Vector3.new(0, 1, 0))}):Play()
tweenservice:Create(maxwell, info2, {CFrame = maxwell.CFrame * CFrame.Angles(0, 360, 0)}):Play()
1 Like

I am confused, as this is what happens for me…

the whiskers do move now, but it does nothing like what it’s supposed to…

Yeah, i just noticed that while using CFrame, you can’t do a double tween on the same object, only one of both will work (didn’t knew that :/).

So, you can delete the welds, i’m giving you another method.

local TweenService = game:GetService("TweenService")
local RunService = game:GetService("RunService")

local Maxwell = script.Parent
local Part = Instance.new("Part")

local Info1 = TweenInfo.new(0.8, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, -1, true)
local Info2 = TweenInfo.new(2.5, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, -1, false)

Part.CFrame = Maxwell.PrimaryPart.CFrame
TweenService:Create(Part, Info1, {Position = Part.Position + Vector3.new(0, 1, 0)}):Play()
TweenService:Create(Part, Info2, {Rotation = Part.Rotation + Vector3.new(0, 360, 0)}):Play()

while RunService.Heartbeat:Wait() do
	Maxwell:PivotTo(Part.CFrame)
end
1 Like

Thank you so so much! It works perfectly now!

1 Like

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