Animation will not play

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to add a running animation to the player so that when they walk around, the animation will play.

  2. What is the issue? Include screenshots / videos if possible!
    The script that I have is not working in my game. However if I put it in an empty baseplate, it works. This code is in a localScript.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Searching around the web, discord, asking friends, etc.

wait(8)
print("gl")


local animate = game.Players.LocalPlayer.Character:FindFirstChild("Animate")
local walk = animate.walk
local run = animate.run

if not walk:FindFirstChild("PreviousAnimation") then
	local newVal = Instance.new("StringValue")
	newVal.Value = walk.WalkAnim.AnimationId
	newVal.Name = "Previous"
	newVal.Parent = walk
end

walk.WalkAnim.AnimationId = "http://www.roblox.com/asset/?id=6084665257" --run animaation.

if not run:FindFirstChild("PreviousAnimation") then
	local newVal = Instance.new("StringValue")
	newVal.Value = run.RunAnim.AnimationId
	newVal.Name = "Previous"
	newVal.Parent = run
end

run.RunAnim.AnimationId = "http://www.roblox.com/asset/?id=6084665257" --run animaation.

How can I fix this?

I don’t want it to play when I press a button, I don’t want to have it constantly play by using animation:Play(). I just want it to play when the player moves.

1 Like

Sounds like one of your scripts in your main game is conflicting with this script. Do you get any errors when you run it in your main game?

No other script is interfering. This is the only script that messes with animation. I get no errors either. My animation ID will change but it will still play the normal walking animation…

You can change the player’s animations in their HumanoidDescription which doesnt work for me;
however you can also change all animations for the player, they are stored inside of Player.Animate which is the animate script, I can give you code from a project I was working on if you need help