Animations not playing, no errors in the output

I’m trying to make a sword system, when clicking it plays an animation and when it stops if the player waits 2 seconds before clicking again, the animation count resets, if he doesnt wait, the second slash animation plays, and so on.

For some reason the animations aren’t playing, i’ve checked if the animations are correct, they are set to action, and it still doesnt work, and there arent any errors in the output. This is the normal script in the sword

local Turn = 1
local Cooldown = 2 

script.Parent.Activated:Connect(function()
	if script.Parent.Cooldown.Value == false then
		script.Parent.Cooldown.Value = true
		script.Parent.CanDamage.Value = true
		wait(1)
		local humanoid = script.Parent.Parent.Humanoid
		
		local Animation1 = script.Animation1
		local Animation2 = script.Animation2
		local Animation3 = script.Animation3
		local Animation4 = script.Animation4
		local Animation5 = script.Animation5

		if Turn == 1 then
			local Anim1 = humanoid:LoadAnimation(Animation1)
			Anim1:Play()
			Turn = 2

			Anim1.Stopped:wait(Cooldown)
			script.Parent.CanDamage.Value = false
			script.Parent.Cooldown.Value = false
		elseif Turn == 2 then
			local Anim2 = humanoid:LoadAnimation(Animation2)
			Anim2:Play()
			Turn = 3

			Anim2.Stopped:Wait(Cooldown)
			script.Parent.CanDamage.Value = false
			script.Parent.Cooldown.Value = false
		elseif Turn == 3 then
			local Anim3 = humanoid:LoadAnimation(Animation3)
			Anim3:Play()
			Turn = 4

			Anim3.Stopped:Wait(Cooldown)
			script.Parent.CanDamage.Value = false
			script.Parent.Cooldown.Value = false
		elseif Turn == 4 then
			local Anim4 = humanoid:LoadAnimation(Animation4)
			Anim4:Play()
			Turn = 5

			Anim4.Stopped:Wait(Cooldown)
			script.Parent.CanDamage.Value = false
			script.Parent.Cooldown.Value = false
		elseif Turn == 5 then
			local Anim5 = humanoid:LoadAnimation(Animation5)
			Anim5:Play()
			Turn = 1

			Anim5.Stopped:Wait(Cooldown)
			script.Parent.CanDamage.Value = false
			script.Parent.Cooldown.Value = false
		end
	end
end)

Additionally, i have 2 boolvalues in the tool, and the sword mesh. The animations are under the script

image_2023-08-06_001610002

I have no idea why this isn’t working, and i’ve literally stayed up all night trying to figure it out watching different videos and looking at similar posts, but I still have nothing

4 Likes

Have you tried playing the animations separately in a Local Script? That’s what I do in my games.

4 Likes

I’m not sure I quite understand what you mean, like swap the normal script with a local script?

5 Likes

Here are the reasons I think its not working:

  1. Animation priority is too low that its getting overriden by diff anims (roblox animate in this example)
  2. Use of humanoid instead of Animator. Use Animator instead (humanoid objects of the character has a Animator)
  3. LocalScripts are more recommended to play anims in

Change the anim priority to action or smth higher then try again
edit: typo

3 Likes

Are the animations loaded? Roblox engine seems to have issues loading things from scripts during the game… Might be the root of your problem too.

5 Likes

I tried that before and I also tried the local script and also the priority is action but it still doesnt work

3 Likes

Yeah but that didn’t seem to work anyways but I was wondering if you have published the animations because Roblox doesn’t allow an animation to play if it’s not yours.

3 Likes

Try loading the animation into humanoid.Animator instead of just humanoid.
Turn off RequiresHandle in your tool

Try those.

4 Likes

Thanks it worked, but now something else is happening, when it gets to the third animation, it just spams it, like it doesnt stop and just keeps playing it constantly

1 Like

Make sure it’s not looped, and make sure your hit counter is updating

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.