Hi, I’m new to motor6Ds and animating in general, I’ve made an animation with a model, which is not a tool but now I made the animation play with a script but the model does not move from its position on the character, can someone help me? (I wanna avoid using tools)
local plr = game:GetService("Players").LocalPlayer;
local rs = game:GetService("ReplicatedStorage");
local mouse = plr:GetMouse();
local char = plr.Character;
local event = rs.bowEvents.equipBow;
local playing = true;
mouse.KeyDown:Connect(function(key)
if key == "1" and playing then
event:FireServer();
playing = false;
wait(4);
playing = true
end
end)
server script:
local rs = game:GetService("ReplicatedStorage");
local equipEvent = rs.bowEvents.equipBow;
---- local functions ----
local function playEquip(plr)
local char = plr.Character
local anim = Instance.new("Animation");
local motor = char:FindFirstChild("HumanoidRootPart").Handle --it's the motor's name
motor.Part0 = motor.Parent
motor.Part1 = char:FindFirstChild("standardBow").Handle -- handle in this case is the part's name
anim.AnimatioNid = "rbxassetid://" -- i removed the id, but in my script it exists so the animation plays correctly
local animH = char.Humanoid:LoadAnimation(anim);
if char.Humanoid.Health ~= 0 then
animH:Play()
else
animH:Stop()
end
end
equipEvent.OnServerEvent:Connect(playEquip)
Hello, thank you for answering.
I’m not really sure about “creating the Motor6D which is attached to the bow”
I create the motor6D with a script:
game.Players.PlayerAdded:Connect(function(plr)
local char = plr.Character
local motor = Instance.new("Motor6D")
motor.Name = "Handle"
motor.Parent = char:FindFirstChild("HumanoidRootPart")
Then the other script sets the part0 and part1, could you please elaborate?
Thank you.
As I thought, when you create a Motor6D the C0 and C1 properties which position the part0 and part1 properties correctly get reset to CFrame.new(). Here is a visualization using RigEdit of what happens when you create a new Motor6D using Instance.new() vs a rig created using RigEdit or any other rig editing plugin:
To fix this clone the Motor6D from the animation rig in the dummy instead of creating a new one in order to preserve the C0 and C1 properties or else the animation will look weird.