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

Stop is not a valid member of Animation "Animation" Same goes for Play???

Asked by
L30N_C 27
4 years ago

This script does so that a anim plays when your walking sideways but the problem is that this happends:

Stop is not a valid member of Animation "Animation" Play is not a valid member of Animation "Animation" Why??

Heres the localscript:

local plr = game.Players.LocalPlayer
local char = plr.Character
local hum = char:WaitForChild("Humanoid")
local UserInputService = game:GetService("UserInputService")

local leftWalk = Instance.new("Animation")
leftWalk.AnimationId = "rbxassetid://6046738829"

local rightWalk = Instance.new("Animation")
rightWalk.AnimationId = "rbxassetid://6046765944"

hum:LoadAnimation(leftWalk)
hum:LoadAnimation(rightWalk)

UserInputService.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.D then
        print("Going Right")
        rightWalk:Play()
    elseif input.KeyCode == Enum.KeyCode.A then
        print("Going Left")
        leftWalk:Play()
    end
end)

UserInputService.InputEnded:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.D then
        print("Animation Stop")
        rightWalk:Stop()
    elseif input.KeyCode == Enum.KeyCode.A then
        print("Animation Stop")
        leftWalk:Stop()
    end
end)

1 answer

Log in to vote
0
Answered by 4 years ago

You need to asign :LoadAnimation to a variable. For Example:

leftAnim = hum:LoadAnimation(leftWalk)
rightAnim = hum:LoadAnimation(rightWalk)

After you do this leftAnim:Play() or rightAnim:Stop() will work.

0
Oh ok thank you!! L30N_C 27 — 4y
0
I would appreciate if you accepted this answer if it helped you. We both get rep for it. vonotige 49 — 4y
Ad

Answer this question