So basically, I’ve been trying to create an animation with a prop in hand (not a tool) that is triggered by a seat. The issue I’m running into is that I don’t know how to rotate the sword prop or position it correctly for the animation. I can’t tell if I’m going about this the right way either, so any suggestions will help!
For an in-depth explanation of what I have so far,
To start: I created an animation within Moon Animator & the prop together (this is the animation I’m using for reference);
Then I created the following script & put it into the seat, so that when the animation is activated it spawns in the sword prop, creates a Motor6D to assign the sword prop to the CFrame of the right hand:
local seat = script.Parent
local sword = workspace.TestingSword
local currentAnim = nil
local clonedSword = nil
function CreateWeld(From,To)
if not (From and To) then return end
if not To:IsA("BasePart") then return end
local Weld = Instance.new("Motor6D") Weld.Part0 = From Weld.Part1 = To
Weld.C0 = From.CFrame:inverse() * From.CFrame
Weld.C1 = To.CFrame:inverse() * From.CFrame
Weld.Parent = To return Weld
end
seat:GetPropertyChangedSignal("Occupant"):Connect(function()
local Humanoid = seat.Occupant
if Humanoid then --Enables the animation
clonedSword = sword:Clone()
clonedSword.Name = "ClonedSword"
clonedSword.CFrame = Humanoid.Parent.RightHand.CFrame
clonedSword.Parent = Humanoid.Parent
CreateWeld(Humanoid.Parent.RightHand,clonedSword)
currentAnim = Humanoid:LoadAnimation(seat.sitanim)
currentAnim:Play()
else --Disables the animation
clonedSword:Destroy()
currentAnim:Stop()
currentAnim:Destroy()
end
end)
Which as a result, plays out like this
I got the blade to be attached, but it’s not in it’s correct orientation (the same position as seen within the animator) - any idea what I could be doing wrong?
Any help is appreciated! Thanks!