I made a simple sword and want to activate an animation from the tool. I can't seem to get it to play and can't figure why any help will be greatly appreciated!
All parts are Welded together not anchored, and Collide is turned on only in Handle atm
I have animated and published the animation to roblox and attached id to animation named "SwordSlash"
local Tool = script.Parent
--Variables
local swordAnim
--Animations
local swordSlash = Tool.Handle.SwordSlash
Tool.Activated:Connect(function()
local humanoid = Tool.Parent:FindFirstChildWhichIsA("Humanoid")
if humanoid then
local animator = humanoid:FindFirstChildOfClass("Animator")
if animator then
swordAnim = animator:LoadAnimation(swordSlash)
print("Got Here")
swordAnim:Play()
wait(1)
end
end
end)
I have tried different varations with Stop() and debounce, but kept simplifying to try to get it working. Lastily I added the animator line since, I read that Humanoid:LoadAnimation was deprecated. I can get the sword out and the print "Got Here" to run ,but animation doesn't play. If anyone has any insight I would love some help on this Thanks! - Froxty

3 comments
https://ibb.co/nRbL0yF
From what I read on Roblox API (https://developer.roblox.com/en-us/api-reference/class/Animator). From what I read the animator is created automatically when Humanoid:LoadAnimation or AnimationController:LoadAnimation is called. I added line 13-14 to find for the generated animator and use it to play animation track saved as swordanim.
I previously didn't have those lines and had it down to just find humanoid and local animationTrack = Humanoid:LoadAnimation(Slash) and it wasn't working with that either so, I tried the lines above - I believe it's reference correctly tho.