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

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

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

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.

2 comments

0

Oh ok thank you!!

0

I would appreciate if you accepted this answer if it helped you. We both get rep for it.

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