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:

local tool = script.Parent.Parent.Parent.M16A4
local anim1 = script.Parent.EquipAnimation

tool.Equipped:Connect(function()
    anim1:Play()
end)

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


local anim1 = script.Parent.EquipAnimation local anim2 = Player.Character.Humanoid:LoadAnimation(anim1) anim2: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.

local tool = script.Parent.Parent.Parent.M16A4
local anim1 = script.Parent.EquipAnimation

tool.Equipped:Connect(function()
   local anim2 = Player.Character.Humanoid:LoadAnimation(anim1)
anim2:Play()
end)

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