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

Play isn't a valid member of animation?

Asked by 5 years ago

So I want a animation to play when I equip the gun, To make it look like your taking the gun out of it's holster. I have an animation inside of the gun's Handle, And a Local script inside the handle too. And I have this:

1local tool = script.Parent.Parent.Parent.M16A4
2local anim1 = script.Parent.EquipAnimation
3 
4tool.Equipped:Connect(function()
5    anim1:Play()
6end)

VERY simple, And for some reason its not working??

1 answer

Log in to vote
1
Answered by 5 years ago

Ok, you must not know much about animation or scripting cause this is very simple. Anyway when scripting a animation you always have to load it. Such as: In this script I'm assuming you already have the Player set as a variable

1local anim1 = script.Parent.EquipAnimation
2local anim2 = Player.Character.Humanoid:LoadAnimation(anim1)
3anim2:Play()

This script is basically getting the animation. Once got it loaded it into your humanoid. Then Plays it. Now lets imply this into your script. And i will assuming you already have the correct variables.

1local tool = script.Parent.Parent.Parent.M16A4
2local anim1 = script.Parent.EquipAnimation
3 
4tool.Equipped:Connect(function()
5   local anim2 = Player.Character.Humanoid:LoadAnimation(anim1)
6anim2:Play()
7end)

If this helped you please give it a answeared thingy

Regards, Bl_ueHistory

0
This makes much more sense, But now its not saying its a valid member of the Handle? Mrmonkeyman120 65 — 5y
0
Nvm I got it working, I just used, :FindFirstChild() to get it. Thanks! Mrmonkeyman120 65 — 5y
Ad

Answer this question