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

Play isn't a valid member of animation?

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

✓ Accepted answer

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

2 comments

0

This makes much more sense, But now its not saying its a valid member of the Handle?

0

Nvm I got it working, I just used, :FindFirstChild() to get it. Thanks!

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