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

Play() Is not a valid member of Animation. How to fix it?

Hello, im making a tool and i make a animation on it. when i test my tool it dosen't play and the output tells me: 17:16:59.005 - Play is not a valid member of Animation 17:16:59.009 - Stack Begin 17:16:59.014 - Script 'Workspace.TheEdyGamerTroll23.Chip.LocalScript', Line 12 17:16:59.018 - Stack End

Here's my script

Tool = script.Parent
local player = game.Players.LocalPlayer
repeat wait() until player.Character ~= nil
local hum = player.Character:WaitForChild("Humanoid")


local animation = Tool["insert-2"]
local animation2 = Tool["insert-1"] 
local AnimTrack = hum:LoadAnimation(script.Parent["insert-1"]) 

Tool.Activated:connect(function(mouse)
    animation2:Play()
end)

Tool.Unequipped:connect(function() 
    animation2:Stop()
end)

2 comments

0

also the same with Stop()

0

The Activated event doesn’t have a mouse parameter.

1 answer

✓ Accepted answer

Animations do not have a method called Play, only the AnimationTracks which are returned after loading the animation on a humanoid.

Something like this should work:

Tool = script.Parent
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")

local animation = Tool["insert-2"]
local animation2 = Tool["insert-1"] 
local AnimTrack2 = hum:LoadAnimation(animation2)

Tool.Activated:connect(function(mouse)
    AnimTrack2:Play()
end)

Tool.Unequipped:connect(function() 
    AnimTrack2:Stop()
end)

If you also want to play the first animation, you will have to create a separate track for it. Also, make sure the AnimationPriority is action if the animation doesn't seem to work; you can do this by going:

AnimTrack2.Priority = Enum.AnimationPriority.Action

Hope this helps!

4 comments

0

Thanks Dude, it worked!

0

No problem (:

0

Hey dude why won't my arm move while in animation?

0

As I said, try changing the priority to action.

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