How to tween rotate a model

i want to rotate a model with a twen, not just snap it into place

1 Like

Generally to tween a model you:

  • Decide on a “main part” for the model
  • Set the main part to anchored
  • Set all the other parts to unanchored
  • Weld all the parts together (so it doesn’t fall apart)
  • Tween the main part
5 Likes

i already tried that and it only moves the main part

2 Likes

plus my model is a tool, so it has to all be unanchored

2 Likes

What is the script you’re using to rotate the model? It should look something like this;

local info = TweenInfo.new(1)
local tween = game:GetService("TweenService"):Create(script.Parent,info,{Orientation = Vector3.new(0,360,0)})

script.Parent.Touched:Connect(function(hit)
	local char = hit.Parent
	if char and char:FindFirstChild("Humanoid") then
		tween:Play()
	end
end)
2 Likes

You probably need to tween the CFrame. If you change position or orientation directly, it just adjusts the welds.

If this is the case, then you’ll probably need to tween the weld connecting it to whatever it’s connected to (e.g. the players hand or the handle part)

2 Likes

how do i tween a weld
char limit

3 Likes

I guess the newer welds don’t have CFrame properties. You can still use an older “Weld” object though. To tween a Weld, just tween the Weld.C1 or Weld.C0.

Edit:

I think the newer way to do this is to have attachments in both models, connect them with a RigidJoint, then tween one of the attachment’s CFrame (which is relative to the part it’s under).

3 Likes

If this is a model set the PrimaryPart and rotate that. Or rotate everything together.

2 Likes

like i said i already tried that and it only rotated the primary part, nothing else

2 Likes

Hmmm, well there is always this, A bit crazy I think …

local TweenService = game:GetService("TweenService")
local tool = script.Parent
local model = tool:WaitForChild("Model")
local targetCFrame = CFrame.Angles(math.rad(90), math.rad(0), math.rad(0))

for _, part in pairs(model:GetDescendants()) do
    if part:IsA("BasePart") then
        local goal = {}
        goal.CFrame = part.CFrame * targetCFrame
        local tween = TweenService:Create(part, TweenInfo.new(1), goal)
        tween:Play()
    end
end

A raw version of PrimaryPart tween

local TweenService = game:GetService("TweenService")
local model = workspace:WaitForChild("Model")
local primaryPart = model.PrimaryPart

local targetCFrame = CFrame.Angles(math.rad(90), math.rad(0), math.rad(0))
local goal = {CFrame = primaryPart.CFrame * targetCFrame}
local tween = TweenService:Create(primaryPart, TweenInfo.new(1), goal)
tween:Play()
1 Like

tween a cframe value and set up a .Changed function to use model:PivotTo to rotate the model

2 Likes

like

CFrameValue.Changed:Connect(function(Value)
Model:PivotTo(Value)
end)
2 Likes

i feel like thats a little unoptimized

1 Like

heres what it looks like right now btw: (In this test im moving it, not rotating)

1 Like

are the parts that are supposed to be attached to moving part welded to it?

1 Like

yea they are welded to it with WeldContraints

1 Like

You should try using a rigid constraint then tweening the attachments it’s between if you’re looking to tween it.

Also, here is the more common way to animate tools (using animations instead of Tweens):

1 Like
  • Set a PrimaryPart for your model.
  • Put WeldConstraints in every part in your model except for your PrimaryPart.
  • Set Part0 to the WeldConstraint’s parent and Part1 to the PrimaryPart.
  • Tweening in this way will only work with CFrame, so…
local TweenService = game:GetService("TweenService")
local Model = script.Parent -- Change as needed.
local PrimaryPart = Model.PrimaryPart

local Info = TweenInfo.new(1, Enum.EasingStyle.Linear)

local Goal = {PrimaryPart.CFrame * CFrame.new(0, 5, 0)}

local Tween = TweenService:Create(PrimaryPart, Info, Goal)
Tween:Play()
1 Like

ive already said this, i tried this exact thing and it didnt work