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?

Asked by
Galicate 106
7 years ago
Edited 7 years ago

its a simple line of code and I don't understand why its not working.

01local tool = script.Parent
02local player = game:GetService("Players").LocalPlayer
03local Ammo = script.Parent:WaitForChild("Ammo")
04local HoldAnimation = script.Parent.HoldAnim
05tool.Equipped:connect(function(mouse)
06    print("Tool equipped!")
07 
08    mouse.Button1Down:connect(function()
09        if Ammo.Value >= 1 then
10        print("Mouse pressed!")
11        Ammo.Value = Ammo.Value - 1
12        HoldAnimation:Play()
13        print(Ammo.Value)
14        script.Parent.Handle.Fire:Play()
15        local ray = Ray.new(tool.Handle.CFrame.p, (mouse.Hit.p - tool.Handle.CFrame.p).unit * 300)
View all 63 lines...

it gives me and output that says 18:03:23.044 - Play is not a valid member of Animation

0
Can you show more of the script thanks! Mr_MilkysButler 47 — 7y
0
yea let me edit the post. Galicate 106 — 7y
1
Please send a screenshot of the explorer ok? Really appreciated. OfcPedroo 396 — 7y
0
Probably you made a typo or specified the wrong path. As I said there up, also send a link to a screenshot of the explorer so I can help you. OfcPedroo 396 — 7y
View all comments (6 more)
0
Like use cut tools of windows and select the explorer part. then go to prnt.sc and upload the photo, and pass me the link they will give you. OfcPedroo 396 — 7y
0
(snipping tool) not cut tools. OfcPedroo 396 — 7y
0
ok thx. OfcPedroo 396 — 7y
0
oh and is the script there? OfcPedroo 396 — 7y
0
Yea the script is in the localscript with no name Galicate 106 — 7y

3 answers

Log in to vote
1
Answered by 7 years ago

Okay so you need to load your animations into the humanoid using this function

1local C = player.Character
2local Hum = C:WaitForChild("Humanoid")
3local PlayAnim = Hum:LoadAnimation(HoldAnimation)
4PlayAnim:Play()

-- Hopefully this helped!

0
OMG TRUE, I didn't remember the pre-load thing OfcPedroo 396 — 7y
0
curses, sniped again. DropshipPilot 148 — 7y
Ad
Log in to vote
0
Answered by 7 years ago

You're on the right track! But, in order to play an animation, you have to first Load it onto the Humanoid.

The function Humanoid:LoadAnimation() is how you get an animation on a humanoid, ready to play. This function returns the AnimationTrack object, which is what you use :Play() on.

Example codes: (These use the LocalPlayer as a way of finding your player humanoid, so don't try and use the example copy-paste in anything but a Localscript.)

1humanoid = game.Players.LocalPlayer.Character.Humanoid
2animTrack = humanoid:LoadAnimation(script.Parent.HoldAnim)
3 
4animTrack:Play()

or:

1game.Players.Localplayer.Character.Humanoid:LoadAnimation(script.Parent.HoldAnim):Play()

Link to AnimTrack properties on the wiki. Try messing with Playbackspeed!

Hope this helped.

Log in to vote
0
Answered by
OfcPedroo 396 Moderation Voter
7 years ago
Edited 7 years ago

Shoutout to @Mr_MilkysButler and @DropshitPilot's awesome ideas, try this:

1game.Players.PlayerAdded:connect(function(player)
2    repeat wait() until player.Character
3 
4    local humanoid = player.Character.Humanoid
5    humanoid:LoadAnimation(HoldAnim)
6    HoldAnim:Play()
7 
8end)

Answer this question