Sword Animation?

How do I make it so that when you equip the tool, the sword appears at the back and your hand goes to grab it. Then when you click it swings. I know it takes animation but there is some coding in here that I am not able to figure out.

(Reference from Anime Fighting Sim)

1 Like

Have you tried doing anything to create what you are trying to do? We cannot help you unless you put forth some effort on your end as to what you are trying to achieve; even a snippet of code would help.

1 Like

For attaching the sword on the player back before equipping, I’d suggest you refer to this tutorial.

On tool equipped, you can destroy the accessory attached to the characters back and play an equip animation.

1 Like

Analyzing the video frame-by-frame is pretty helpful here. Look at these two frames:



The animation is fairly quick, but the sword starts on the back. It then shifts to the hand so that you can appear holding it. It would really only take a quick changing of CFrame to accomplish this. With modern methods, it’s also easier and more comfortable than ever to get this done.

Above tutorial’s good for these kinds of things (thanks for the link and mention), though I suggest taking a slightly different approach. You will need to handle the weld management manually so that you can get the best result out of this.

As characters already have attachments in their character, you can use this to your advantage. Set up two attachment points that line up with the character: one that will indicate when the sword is on the character’s back and another where they will grip it by when they want to equip it.

Place the sword in the character. Reconstruct the weld which you would normally get if you were to use the accessory method outlined above. Attach it to their back first.

--- Sample code for placing a sword in a player character.
-- @author colbert2677

local Character = game:GetService("Players"):FindFirstChild("colbert2677").Character
local FireSword = game:GetService("ServerStorage").FireSword

local newSword = FireSword:Clone()
newSword.Parent = Character

local newWeld = Instance.new("Weld")
newWeld.Part0 = newSword
newWeld.Part1 = Character.UpperTorso
newWeld.C0 = newSword.SheathedAttachment.CFrame
newWeld.C1 = Character.UpperTorso.BodyBackAttachment.CFrame
newWeld.Parent = newWeld.Part0

Cool, it’s on their back and you have the weld now. Just need to change the CFrame.

--- Sample code for equipping a sword.
-- @author colbert2677

local Character = game:GetService("Players"):FindFirstChild("colbert2677").Character
local FireSword = Character.FireSword
local FireSwordWeld = FireSword.Weld

FireSwordWeld.Part1 = Character.RightHand
FireSwordWeld.C0 = FireSword.HoldAttachment.CFrame
FireSwordWeld.C1 = Character.RightHand.RightGripAttachment.CFrame

As for when to do these actions, set up keyframe markers in your animation and use GetMarkerReachedSignal. Add a marker where the sword’s weld should be changed from the back to the hand and vice versa for unequipping.