I am attempting to recreate the classic Roblox sword with some slight difference for a game I’m making. I was struggling with getting the animation to work for R6 so I looked at how the original sword does it, the code is copy-pasted below. I copy and pasted it into my script and it just works even though I have no idea how. This is the only reference to animations in the script(except for the lunge function which is the same but the Value = “Lunge”), its inside the slash function. Please explain.
Line 434 in the R6 Animate localscript (Found inside your player character)
function animateTool()
if (toolAnim == "None") then
playToolAnimation("toolnone", toolTransitionTime, Humanoid, Enum.AnimationPriority.Idle)
return
end
if (toolAnim == "Slash") then
playToolAnimation("toolslash", 0, Humanoid, Enum.AnimationPriority.Action)
return
end
if (toolAnim == "Lunge") then
playToolAnimation("toollunge", 0, Humanoid, Enum.AnimationPriority.Action)
return
end
end
The animate script checks for tools, and if they have a StringValue named “toolanim” and have a value such as “Lunge” or “Slash”, it will play said animations.
Since the Animate script is one you get automatically when your character respawns, you really don’t need to load animations in your tool’s script when you can just make a StringValue and use the default animations.
If you want to change the animation, you can copy the Animate script from your character in game and paste it into StarterCharacterScripts and edit the animation ID’s there, do note that it will do it for all tool animations.