Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why won't my animation play?

Asked by 10 years ago

Hello! I am modifying the default script in the linked sword gear to play My own animation. Everything is exactly the same except this part.

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

The animation will not play. In my out put it says: 19:00:42.155 - Play is not a valid member of Animation. I understand it is saying that it does not know what play is in the animation. What do I need to put there to make it play? Oh and the animation is just a simple customized hand swing, If that helps any.

Danke ~Minikitkat

0
Updated my answer. I didn't put anim as an argument NotsoPenguin 705 — 10y
0
What's the animation's priority? Redbullusa 1580 — 10y
0
It is a simple sword swing but customized. minikitkat 687 — 10y
0
I just realized I made the animation a core and not an action. I updated it but that did not do anything. minikitkat 687 — 10y

2 answers

Log in to vote
2
Answered by
Redbullusa 1580 Moderation Voter
10 years ago

The most important thing to note when playing animations is that you must load the animation.

You can do this by using the :LoadAnimation() method. It accepts an animation object with a valid ID of your animation asset.

I'm not entirely sure what your scripting style is, but I prefer to define my variables at the beginning of my script, so that it's ready to use.

Assuming that your animation is not looped, that it's priority is high enough so that it's not overridden by Roblox's default animations, and that this script is a local script, you may try it this way.

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

The reason why I didn't make a new animation in the function is because every time it is called, the script will make a new animation. So the amount of times the function is called is just as much as the animation objects your script will make.

0
This does everything great, but the animation still isn't playing! I am going to see if there is something wrong with the animation in a minute and I will report back. minikitkat 687 — 10y
0
Okay, There is nothing wrong with the animation as I just tested it on my animation testing place. I don't know Why it is not playing though! Any more help? minikitkat 687 — 10y
0
Okay I did what you said and added the repeat until the humanoid was loaded. Thanks! minikitkat 687 — 10y
Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

I have been experiencing this issue to as well, but I found out it requires a ordinary script, not a module script and not a local script. If your still having trouble with using a ordinary script try removing or rescripting (if there is) any scripts that weld the character together, if you need the welding script inside the character to weld a model to its back, simply rescript it so that it will not interact with any parts of the body that require the animation (e.g The torso). >Hope this helped, sincerely HeComesAt_Night.

Answer this question