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 5 years ago

I need help please. Why does it say Play is not a valid member of animation

local plr = game.Players.LocalPlayer
repeat wait()until plr.Character
local humanoid = plr.Character:WaitForChild("Humanoid")


local tool = script.Parent
local NilAnim = script.Nil
local FiringWeaponAnim = script.FiringWeapon
local EquippedWeaponAnim = script.EquippedWeapon

script.Parent.Equipped:Connect(function()
    humanoid:LoadAnimation(EquippedWeaponAnim)
    EquippedWeaponAnim:Play()
    script.Parent.Unequipped:Connect(function()
        print("Unequipped")
    end)
end)

1 answer

Log in to vote
1
Answered by 5 years ago

You need to save the variable of the loaded animation track like so

script.Parent.Equipped:Connect(function()
    local anim = humanoid:LoadAnimation(EquippedWeaponAnim)
    anim:Play()
    script.Parent.Unequipped:Connect(function()
        print("Unequipped")
    end)
end)
Ad

Answer this question