Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why won't my animation play [BUMP]?

I'm not sure if I will get in trouble for posting because no one is answering on my first attempt. After some help from a few people (Big help form Redbullusa), we have come up with this script:

char = game.Players.LocalPlayer.Character
humanoid = char:WaitForChild("Humanoid")

-- You may delete the first two lines if they're already defined.
-- Be sure to replace the 'humanoid' variable to the desired Humanoid object in line 11 if you do.

SlashAnim = Instance.new("Animation")
SlashAnim.Name = "toolanim"
SlashAnim.AnimationId = "http://www.roblox.com/asset/?id=211308302"
SlashAnim.Parent = Tool
SlashAnimLoaded = humanoid:LoadAnimation(SlashAnim)

function attack()
    damage = slash_damage
    SlashSound:play()
    SlashAnimLoaded:Play()
end

It is in the default LinkedSword gear SwordScript. Tgis is the only modification in the script. Everything works very well accept one thing; The animation won't play! Here is the Animation on the site: http://www.roblox.com/Wrench-Swing1-item?id=211308302 The animation is a simple sword slash but is customized by me to swing at an angle. The priority is an action. It is not looped.

Any help?

~Minikitkat

1 answer

Everything besides not calling the function is fine. Functions do not run the code inside unless they are called, as so;

char = game.Players.LocalPlayer.Character
humanoid = char:WaitForChild("Humanoid")

-- You may delete the first two lines if they're already defined.
-- Be sure to replace the 'humanoid' variable to the desired Humanoid object in line 11 if you do. 

SlashAnim = Instance.new("Animation")
SlashAnim.Name = "toolanim"
SlashAnim.AnimationId = "http://www.roblox.com/asset/?id=211308302"
SlashAnim.Parent = Tool
SlashAnimLoaded = humanoid:LoadAnimation(SlashAnim)
 
function attack()
    damage = slash_damage
    SlashSound:play()
    SlashAnimLoaded:Play()
end

attack()

This discussion is preserved as it was. New answers, comments, and votes are closed.