How do I get the position of a Part while in an animation?

Hi! I have viewed and searched many topics already, but none of them seems to help.

The only closest thing to what I want is the Motor6D.transform property, but it’s hidden:

Does anyone know how I can get the position/CFrame of an object during an animation (not tween)? This is because the position/CFrame doesn’t update during animation.

1 Like

You can use the CFrame property of the HumanoidRootPart of the character that is being animated. The HumanoidRootPart represents the root bone of the character’s skeleton, and its CFrame property gives the position and orientation of the character in the world.

Excuse me, but does the HumanoidRootPart update position/CFrame during animation? I kind of need a little bit more clarification.

Yea, the HumanoidRootPart does update its CFrame during animation. When an animation is played on a character, the Humanoid object updates the positions and orientations of the bones in the character’s skeleton, which in turn updates the CFrame of the HumanoidRootPart .

here’s an example

local character = script.Parent.Parent
local humanoid = character:FindFirstChild("Humanoid")

if humanoid then
    local rootPart = humanoid.RootPart
    local animation = humanoid:LoadAnimation(<animation>)

    while animation.IsPlaying do
        local currentPosition = rootPart.CFrame.p

Thank you so much! This is so helpful! =)

1 Like

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