Player animation not running

Hello!

I’m currently trying to play an animation when the client receives an event signal after reaching an objective. Simply put, the animation doesn’t play.

Here is my relevant code:

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local humRoot = char:WaitForChild("HumanoidRootPart")
local hum = char:WaitForChild("Humanoid")

-- Animations
local ffAnimID = "rbxassetid://11525420159"
local animator = hum:WaitForChild("Animator")

local ffAnim = Instance.new("Animation")
ffAnim.AnimationId = ffAnimID

local ffAnimTrack = animator:LoadAnimation(ffAnim)
ffAnimTrack.Looped = true
ffAnimTrack.Priority = Enum.AnimationPriority.Action

local function animPlay()
     ffAnimTrack:Play()
end

animPlay()

There are no errors in the output.

I have looked through other devforum posts similar and I can’t seem to find a solution. I own this animation. The script is placed in StarterPlayerScripts, but I’ve also tried StartCharacterScripts before. I’ve also tried changing the animation priority and loading the animation through the humanoid.

In case it’s relevant, in the same script I have a function that uses ContextActionService to bind actions at a higher priority than the base movement keys, disabling movement entirely. However, I’ve tried removing the binds and nothing seems to change so I doubt that this is the cause.

Any idea why this might be?

1 Like

Have you also tried re-exporting the animation as action, instead of setting it in a script? Also, try doing the same with looped.

1 Like

Unfortunately, it doesn’t seem to work - I tried two exports set at Action and Movement. Both had looping enabled.

Try change

local function animPlay()
     ffAnimTrack:Play()
end

animPlay()

to

ffAnimTrack:Play()

This is the first thing that pops up in my head

1 Like

Setting an animation’s looped property only works after playing, try playing your animation before setting looped.

1 Like

That doesn’t seem to solve the problem, but possibly a future one. I’ve added that fix in anyways for when the animation actually does work, but as of now, the problem persists.

1 Like

Is the animation asset published under your user or a group that you own?

1 Like

Yeah, It’s published under my group.

I’ve remade the script so you can see if it helps. Yet, I do not believe it is the script itself that is the issue, but the animation.

Here:

local Players = game:GetService("Players")

local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")

local rootpart = character:WaitForChild("HumanoidRootPart")

function PlayAnimation(animator, id)
   local Template = Instance.new("Animation")
   Template.AnimationId = "rbxassetid://" .. id
   return animation animator:LoadAnimation(Template)
end

PlayAnimation(humanoid.Animator, 11525420159)

If the issue pursues, make sure it isn’t the animation asset itself that is having issues, and you may set Looped and Priority properties inside the animation editor before publishing, these will take effect when loading the animation later on with a script.

1 Like

I tested this and it also doesn’t work, however, I have realized the problem (And I feel pretty dumb for not realizing it)

This is a team create session, and another member changed the game setting to only allow R15 users. The animation is R6. Welp, at least I know now. Thanks for all the help

I found the solution - and it’s kind of dumb.

Another member of the group changed the game settings to R15 users only, the animation is R6. So be sure to communicate with your team members, and maybe not be as stupid as me.

Thanks for everyone’s help

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.