I decided to add animations to the bat and installed animations from the toolbox, but there is a problem: this animation finds the Motor6D
in the path Character>Bat>Handle>Bat:Motor6D.
I create a bat model with this motor, but for some reason the animation is not applied to this Motor6D, although other parts of the body move.
local Hitbox = require(game.ReplicatedStorage.SimpleHitbox) -- not using rn
local Tool = script.Parent
local ToolModel = game.ReplicatedStorage.ToolsModels.Bat
local _cache = {}
local Anims = {}
for i,a in pairs(Tool.Anims:GetChildren()) do
Anims[a.Name] = a
end
local Equip:AnimationTrack = nil
local Idle:AnimationTrack = nil
local function clearCache()
for i,v in pairs(_cache) do
v:Destroy()
end
end
Tool.Equipped:Connect(function()
local new = ToolModel:Clone()
local char = Tool.Parent
local hum = char:FindFirstChild("Humanoid")
local connect = Instance.new("Motor6D")
connect.Name = "Bat"
connect.Part0 = char:WaitForChild("Right Arm")
connect.Part1 = new.Bat
connect.Parent = new.Handle
connect.C0 = CFrame.new(0, 1.19, 0) * CFrame.Angles(math.rad(90), math.rad(180), 0)
new.Parent = char
table.insert(_cache, new)
table.insert(_cache, connect)
Equip = hum.Animator:LoadAnimation(Anims["eq"])
Idle = hum.Animator:LoadAnimation(Anims["id"])
Equip:Play()
Equip.Ended:Connect(function()
Idle:Play()
end)
end)
Tool.Unequipped:Connect(function()
clearCache()
Idle:Stop()
end)
What it looks like in the stock model:
