i want to rotate a model with a twen, not just snap it into place
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
i already tried that and it only moves the main part
plus my model is a tool, so it has to all be unanchored
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)
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)
how do i tween a weld
char limit
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).
If this is a model set the PrimaryPart and rotate that. Or rotate everything together.
like i said i already tried that and it only rotated the primary part, nothing else
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()
tween a cframe value and set up a .Changed function to use model:PivotTo to rotate the model
like
CFrameValue.Changed:Connect(function(Value)
Model:PivotTo(Value)
end)
i feel like thats a little unoptimized
heres what it looks like right now btw: (In this test im moving it, not rotating)
are the parts that are supposed to be attached to moving part welded to it?
yea they are welded to it with WeldContraints
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):
- 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()
ive already said this, i tried this exact thing and it didnt work