I made a swing animation for my weapon but it doesnt seem to be working. On all the tutorials I watched they seem to work but for mine it, for some reason, does not.
CODE
script.Parent.Activated:Connect(function()
local animation = script.Animation
local humanoid = script.Parent.Parent.Humanoid
local animationtrack = humanoid:LoadAnimation(animation)
animationtrack:Play()
end)
Humanoid:LoadAnimation() is a deprecated function, your gonna have to try using Animator:LoadAnimation()
script.Parent.Activated:Connect(function()
local animation = script.Animation
local humanoid = script.Parent.Parent.Humanoid
local Animator = humanoid:WaitForChild("Animator")
local animationtrack = Animator:LoadAnimation(animation)
animationtrack:Play()
end)
Does the tool actually change the .Activated property? Is the track looping?
Does the animation have the “Action” animation priority? try animationtrack.Priority = Enum.AnimationPriority.Action
Also I would not recommending reloading the animation each time you want to play it. Initilize it once then just play it each time to keep scripts clear.
local player = game:GetService("Players").LocalPlayer
script.Parent.Activated:Connect(function()
local animation = script.Animation
local animator = Players.Character.Humanoid.Animator
local animationtrack = animator:LoadAnimation(animation)
animationtrack:Play()
end)
I changed some things here, but if this doesnt helps then there are other problems. Maybe your Animation is empty?
Yes, he did it, I asked him some time ago. Also he isn’t getting any errors, this means that Animation is inside weapon. Reasons why Animation may not work:
Open your Animation in animation editor. There are 3 dots somewhere in top left corner, click on them and set AnimationPriority to Action. Save your Animation again and paste new AnimationId to Animation that is inside the script.