Why does this animation not play?

Hey guys, I’m making a knife in studio, but the animation I made for it doesn’t seem to want to play.
Heres my code

local animations = {"5481335398"} -- put ur animation ids here
local CanAttack = true

script.Parent.Activated:Connect(function()
if CanAttack == true then
script.Parent.CanDamage.Value = true
local animation = Instance.new("Animation",  script.Parent.Parent)
animation.AnimationId = "http://www.roblox.com/asset?id="..animations[math.random(1, #animations)]
local chosenanim = script.Parent.Parent.Humanoid:LoadAnimation(animation)
chosenanim:Play()
CanAttack = false
wait(1)
CanAttack = true
script.Parent.CanDamage.Value = false
end
end)

Thanks guys

Maybe this doesn’t help, but try using rbxassetid://.

animation.AnimationId = "rbxassetid://"..animations[math.random(1, #animations)]
1 Like

No, it didn’t help sadly 30charsacters

It could be either the value “CanDamage” doesn’t exist, causing an error and making the script break before an animation plays, or maybe the animation isn’t in your inventory/made by you, and it won’t load because of that.

I tried this out, and it seems to work fine.

1 Like

Ok, I’ll do some investigating, but I must ask if you know how to do this How To Make It So The Last Player Alive Gets A Win?
@OsanaRumia

Make sure your animation priority is set to “Action”.

1 Like

Ahh, so that’s what was wrong! TYSM!

1 Like