Boss Animations Don't work

Hello! So im trying to make a boss battle, I got the animations made and all but the script itself doesnt work

The Script

local Boss = script.Parent
local character = script.Parent
local humanoid = character:FindFirstChild("Humanoid")
local AttackList = {"Punch", "Stomp", "Drill"}
local ChosenAttack = "None"
local IdleAnim = script.Idle
local PunchAnim = script.Punch
local StompAnim = script.Stomp
local DrillAnim = script.Drill
local DeathAnim = script.Death

local animationTrack = humanoid:LoadAnimation(IdleAnim)

animationTrack:Play()

while true do
	wait(5)
	ChosenAttack = AttackList[math.random(1, #AttackList)]
	if ChosenAttack == "Punch" then
		PunchAnim:Play()
		wait(1)
		local exp = Instance.new("Explosion")
		exp.Name = "Explosion"
		exp.Parent = Boss["Right Arm"]
		exp.Position = Boss["Right Arm"]
		wait(1)
		exp:Destroy()
	end
	
	if ChosenAttack == "Stomp" then
		StompAnim:Play()
		wait(1.12)
		local exp = Instance.new("Explosion")
		exp.Name = "Explosion"
		exp.Parent = Boss["Right Leg"]
		exp.Position = Boss["Right Leg"]
		wait(1)
		exp:Destroy()
	end
	
	if ChosenAttack == "Drill" then
		wait(3.2)
		local exp = Instance.new("Explosion")
		exp.Name = "Explosion"
		exp.Parent = Boss["Right Arm"]
		exp.Position = Boss["Right Arm"]
		wait(1)
		exp:Destroy()
	end
	if Boss.Humanoid.Health == 0 then
		DeathAnim:Play()
		break
	end
end

The Error

  09:27:40.131  Play is not a valid member of Animation "Workspace.Dummy.AttackHandler.Stomp"  -  Server - AttackHandler:31
  09:27:40.132  Stack Begin  -  Studio
  09:27:40.132  Script 'Workspace.Dummy.AttackHandler', Line 31  -  Studio - AttackHandler:31
  09:27:40.132  Stack End  -  Studio

You didn’t load the animation. :moyai::moyai::moyai:

1 Like

To play an animation, you first need to load it to the humanoid, in the most recent updates “Animator” was added, so you should do humanoid.Animator:LoadAnimation(StompAnim) instead of trying to index :Play() with an instance.

3 Likes

Like this?

		local animator = humanoid:FindFirstChildOfClass("Animator")
		if animator then
		animator:LoadAnimation(PunchAnim)
		PunchAnim:Play()

N-no, please do this.

humanoid:LoadAnimation(PunchAnim):Play()
2 Likes