Tweening instantly snapping to its goal position

local TweenService = game:GetService("TweenService")
local ToolStand = workspace.ToolStand
local ToolCFrames = ToolStand.ToolCFrames
local AxeFolder = ToolStand.Axes

local Info = TweenInfo.new(2,Enum.EasingStyle.Linear,Enum.EasingDirection.In,1,false)
script.Parent.MouseButton1Click:Connect(function()
	local AxePosition = TweenService:Create(workspace.ToolStand.Axes.WoodenAxe.PrimaryPart,Info,{
		Position = AxeFolder.WoodenAxe:SetPrimaryPartCFrame(ToolCFrames.Axes.LowerRack["1"].CFrame)})
	AxePosition:Play()
end)

This script is supposed to move an axe back to its rack, but even though I’ve set the time for 2 seconds, it instantly pops into place just as it would if I told it to change its position

I believe you are attempting to move the position of the primarypart so instead of:
{Position = AxeFolder.WoodenAxe:SetPrimaryPartCFrame(ToolCFrames.Axes.LowerRack["1"].CFrame)}
it should be: (I think)
{Position = ToolCFrames.Axes.LowerRack["1"].CFrame.Position)}

No errors, but now nothing moves

Are you sure ToolCFrames.Axes.LowerRack["1"].CFrame.Position is not equal to the position its already at?

I’m sure. The axe is the starting position and the red part is the goal:

image

Try tweening the primarypart’s cframe instead of its position.

Should I replace Position = with CFrame =?

Hmmm… thats strange. Am i right in assuming the rotation should also be the same as the red part? If so, perhaps try this:

local AxePosition = TweenService:Create(
    workspace.ToolStand.Axes.WoodenAxe.PrimaryPart,
    Info,
    {CFrame = ToolCFrames.Axes.LowerRack["1"].CFrame}
)

Still nothing moves. There’s also no errors still

It’s actually ONLY moving the primary part, and nothing else follows. I just didn’t notice at first because that part is invisible.

Ah nice, in that case you can use weldconstraint to anchor every other part to the primary part. Make sure the primary part is anchored, and everything else unachored

That’s an issue though. That axe is animated and I’ve tried welding parts together before this and all animations on it halt.

oof, Im sorry to hear that as I’m not too familiar with animations, and so i can’t help further. Though as i leave, i found this, which might help solve your problem: Introduction to Tweening Models - Community Tutorials

I haven’t read the post, so i can’t guarantee if it has the answers, but it might be worth checking out.

Thank you for the post and trying to help me out!

1 Like

No problem :+1:
‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎

1 Like

If it’s animated with keyframes, you just need to keep the animation paused at the end of the animation or at a set keyframe event. If you’re trying to move the axe through CFraming, you have to pivot the entire model to the location using Model:PivotTo(). You can tween the model use a CFrame value and use the Changed event to detect the CFrame tween, then use PivotTo() to CFrame the model accordingly. Since you’ve already animated the axe’s movement, you can just pause the animation.

The animations are separate from what I’m trying to do currently. The animations lift up the axe and spin it around when you click on it. What I’m trying to accomplish here is getting the Axes onto the rack and bringing forward the shovels on the top rack.

Alright so then you use a CFrame value and TweenService to tween the CFrame value back to the rack, and use the Changed event to make the model follow that CFrame. Or you can use a Bezier curve module to tween it for you.

May I get some example code? I’m not understanding 100%

Yeah sure:

local CFrameValue = YourAxeModel.CFrameValueObject or Instance.new("CFrameValue")

local CFrameConnection = CFrameValue.Changed:Connect(function()
    YourAxeModel:PivotTo(CFrameValue.Value)
end)

local AxeTween = TweenService:Create(CFrameValue, AxeTweenInfo, {
    Value = AxeEndCFrame
})
AxeTween:Play()
AxeTween.Completed:Wait()
CFrameConnection:Disconnect()