Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why is my sword animation not playing?

So I have made a sword animation and it is supposed to play when you click. The animation, however, does not play and I am wondering why.

The animations are a child of the local script. I used the animation editor. I made an r15 mesh character. The sword I made was not attached to the dummy while I animated. I tried to do that and it didn't work. When I tried that I did not weld them together.

My character just stands there the dummy still takes the damage. Here is the animation code:

local CanAttack = true

script.Parent.Equipped:Connect(function()
	local idle = script.Parent.Parent.Humanoid:LoadAnimation(script.Idle)
	local attack = script.Parent.Parent.Humanoid:LoadAnimation(script.Attack)
	
	idle:Play()	
end)
script.Parent.Activated:Connect(function()
	local idle = script.Parent.Parent.Humanoid:LoadAnimation(script.Idle)
	local attack = script.Parent.Parent.Humanoid:LoadAnimation(script.Attack)
	
	if CanAttack == true then
		attack:Play()
		idle:Stop()
		CanAttack = false
		wait(1)
		attack:Stop()
		idle:Play()
		CanAttack = true
		script.Parent.CanDamage.Value = true
	end
end)

Here is the damage code:

script.Parent.Blade.Touched:Connect(function(p)
	if script.Parent.CanDamage.Value == true then
		script.Parent.CanDamage.Value = false
		p.Parent.Humanoid:TakeDamage(10)
	end
end)

Comment if you need more info. All help is appreciated! Thanks in advance.

1 answer

✓ Accepted answer

Make sure the priority of the animation is set to Action in the animation editor. There doesn't seem to be an issue with your code here.

2 comments

0

Let me test that. Thank you for your response.

1

It worked! Thank you.

This discussion is preserved as it was. New answers, comments, and votes are closed.