Sword Animation LocalScript printing everything but not running

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? I want to have a sword Animation, that plays everytime you click, and I will add a debounce!

  2. What is the issue? I’ve done everything I am supposed at least I think but when I click the animation doesn’t play but it prints

  3. What solutions have you tried so far? I did look on the developer forum and found either to advanced sword scripts or just people chatting about it. and I made it a function instead of calling it when it is activated

local function AnimationPlay()
	local player = game.Players.LocalPlayer
	local char = player.Character or player.CharacterAdded:Wait()
	local humanoid = char.Humanoid
	local animation = Instance.new("Animation")
	animation.AnimationId = "rbxassetid://6361091778"
	local animTrack = humanoid:LoadAnimation(animation)
	animTrack:Play()
	print(char)
end

script.Parent.Activated:Connect(function()
	AnimationPlay()
end)

Edit: Missed a portion.

2 Likes

I think you forgot to delete the placeholder text…
Edit: Nevermind I think your good! lol, my bad.

Wait what placeholder text? what are you talking about?

Loading an animation through the Humanoid is deprecated, go here to see the updated version!

this is placeholder text I think @gr3uh was talking about???

not sure

Make sure the animation is set to action else it wont work

yes that is true but its still not working.

You should use a ServerScript instead. Heres an example:

local function AnimationPlay(player)
	local character = player.Character
	local humanoid = character:WaitForChild("Humanoid")
	
	local animationId = 00000000 -- animation id here
	local animation = Instance.new("Animation")
	animation.AnimationId = "http://www.roblox.com/Asset?ID="..animationId
	
	local animTrack = humanoid:LoadAnimation(animation)
	animTrack:Play()
end
script.Parent.Activated:Connect(AnimationPlay)

You might wanna change the AnimationPriority to Action as mau said, or double check to make sure that the Animation you’re using is owned by you

Also looking on the API Reference here: