Animation does not want to load

Hi I have an animation and it works in Moon Animator but not in studio. The animation is under the game’s group and not me so it not that. It’s a swing animation and the walking animation works.

ID: rbxassetid://13618755360

Code:

for _,v in pairs(HumanoidParts) do
	if v then
		v.Touched:Connect(function(PlayersPart)
			if DamageDebounce or Humanoid.Health <= 0 then return end
			DamageDebounce = true
			
			if PlayersPart.Parent:FindFirstChild("ThisIsAPlayer") or PlayersPart.Parent.Parent:FindFirstChild("ThisIsAPlayer") then
				local PlayersHumanoid = PlayersPart.Parent:FindFirstChild("Humanoid") or PlayersPart.Parent.Parent:FindFirstChild("Humanoid")
				
				if PlayersHumanoid then
					Humanoid.Animator:LoadAnimation(Humanoid.Parent:FindFirstChild("Swing"))
					PlayersHumanoid:TakeDamage(SCPStats.Damage)
					
					CreateSound(v)
					
					wait(SCPStats.DamageRate)
					DamageDebounce = false
				else
					wait(SCPStats.DamageRate)
					DamageDebounce = false
				end
			else
				wait(SCPStats.DamageRate)
				DamageDebounce = false
				
			end
		end)
	end
end

The reason for this is that you did not call the :Play method when you loaded the animation.

Change this line

Humanoid.Animator:LoadAnimation(Humanoid.Parent:FindFirstChild("Swing"))

And replace it with this (or just add :Play() at the end of the line):

Humanoid.Animator:LoadAnimation(Humanoid.Parent:FindFirstChild("Swing")):Play()

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