Hi,
I made script that should loop the npc animation and if my npc health = 0 then it will stop and play another anim and then npc will destory, but im getting this error

heres script:
local anim1 = game.ReplicatedStorage.NPCAnim1
local anim2 = game.ReplicatedStorage.NPCAnim2
local humanoid = script.Parent.Humanoid
local Track1 = humanoid:LoadAnimation(anim1)
local Track2 = humanoid:LoadAnimation(anim2)
if script.Parent.BoolValue.Value == true then
Track1.Loop = true
Track2:Play()
end
while true do
wait(0.1)
if script.Parent.health.Value <= 0 then
Track1.Loop = false
Track1:Stop()
script.Parent.BoolValue.Value = false
Track2:Play
Track2.Stopped:wait()
npc:Destroy()
end
end
How to fix it?