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

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

Asked by 6 years ago

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)

0
also the same with Stop() TheEdyGamerTroll23 15 — 6y
0
The Activated event doesn’t have a mouse parameter. User#19524 175 — 6y

1 answer

Log in to vote
0
Answered by
mattscy 3725 Moderation Voter Community Moderator
6 years ago
Edited 6 years ago

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!

0
Thanks Dude, it worked! TheEdyGamerTroll23 15 — 6y
0
No problem (: mattscy 3725 — 6y
0
Hey dude why won't my arm move while in animation? TheEdyGamerTroll23 15 — 6y
0
As I said, try changing the priority to action. mattscy 3725 — 6y
Ad

Answer this question