Hi, I am trying to make a “tool holding” animation, the animating part is not an issue, however, the tool isn’t positioned in the same place as in the animation editor when the animation is played. I have attached pictures below to illustrate my point.
This is what it looks like in the animation editor
and this is what it looks like when played
The tool, AK-47, is a model with a part named “AK47_Body”; the part contains a Motor6D that is attached to the head of the Rig that’s being used to animate. The Head is Part0 and AK47_Body is the Part1. The Model of the AK47 itself is parented to the rig.
and in case the code is the issue, here’s the code being used to play the animation(forgive the sloppiness)
The code is housed in a server Script that’s parented in a tool object
local tool = script.Parent
local hold_animation = tool:WaitForChild("Holding_Animation");
local ak = tool:WaitForChild("AK47")
local character = nil;
local humanoid = nil;
local hold_track = nil
tool.Equipped:Connect(function()
character = tool.Parent;
humanoid = character:WaitForChild("Humanoid");
local animator = humanoid:FindFirstChild("Animator");
local root = character:WaitForChild("Head")
local main_body = ak:WaitForChild("AK47_Body");
local joint = Instance.new("Motor6D", main_body);
joint.Part0 = root
joint.Part1 = main_body
hold_track = animator:LoadAnimation(hold_animation)
hold_track:Play()
end)
tool.Unequipped:Connect(function()
character = nil;
humanoid = nil;
hold_track:Stop(0);
hold_track = nil
end)
Thank you.