Making a sword that has a animation when it is activated, Sadly it isn’t working
Script:
local Tool = script.Parent
wait(1)
local Animation = Tool.Slash1
local Player = game.Players
local LocalPlayer = Player.LocalPlayer
local Char = LocalPlayer.Character
local Humanoid = Char:WaitForChild("Humanoid")
local AnimationTrack = Humanoid:LoadAnimation(Animation) --Animations, Important
local debounceTime = 1
Tool.Activated:Connect(function()
AnimationTrack:Play()
print("Playing")
end)
local Tool = script.Parent
wait(1)
local Animation = Tool.Slash1
local Player = game.Players
local LocalPlayer = Player.LocalPlayer
local Char = LocalPlayer.Character
local Humanoid = Char:WaitForChild("Humanoid")
local AnimationTrack = Humanoid:LoadAnimation(Animation) --Animations, Important
local debounceTime = 1
AnimationTrack.Priority = Enum.AnimationPriority.Action
Tool.Activated:Connect(function()
AnimationTrack:Play()
print("Playing")
end)
As a side note, Humanoid:LoadAnimation() is deprecated.
Use Animator:LoadAnimation() instead, e.g.:
local animator = Humanoid:WaitForChild("Animator")
local animationTrack = animator:LoadAnimation(YOUR_ANIMATION)
animationTrack:Play()
BTW, I can’t immediately see any problems with your code, so perhaps it is to do with your animation instance, Slash1. Perhaps try replacing it with another animation to see if that’s the problem.