Animation sometimes plays sometimes does not

The title says it all, i load the animation using a animator, and the animation randomly plays or not. i have no idea what causes this, as it worked perfectly fine a couple weeks ago when i was testing it.

heres the part of the script that plays the animation:

local CameraToSwitch = game.Workspace.Viewmodel2.CameraBone
local animation = game.Workspace.Viewmodel2.IdleAnimation
local humanoid = game.Workspace.Viewmodel2:WaitForChild("Humanoid")
local anim = humanoid.Animator:LoadAnimation(animation)
CurCamera.CameraType = Enum.CameraType.Attach
CurCamera.CameraSubject = CameraToSwitch
CurCamera.CFrame = CameraToSwitch.CFrame
anim:Play()
-- rest of code that isnt important, it gets stuck on the line above

If the animation plays, the script continues and if the animation doesnt play it gets stuck on anim:Play() forever

There are no errors in output btw
edit: i removed the animation.Stopped:Wait(), now the only problem is that the animation randomly doesnt play

2 Likes

What’s the animation’s Priority?

print(anim.Priority)
1 Like

im pretty sure its action, although i tried to change it to action4 - nothing changed it was still randomly playing or not

1 Like

image

1 Like

You could try to add a print before and after the anim:Play() to see if it does everything correctly beforehand

2 Likes

image

1 Like

That’s weird, I actually have no clue

1 Like

Same here, no clue why it doesnt work

1 Like

Can you try and add a boolean before the animation plays and when the animation about to play, check if the boolean were true and then set it to false, not very sure this would work but it definitely something i’d try

Something like this
local needToPlay = true
if needToPlay == true then
 anim:Play()
 needToPlay = false
else 
 print("i ain't going to play bro")
end

Also this is better if you put it in a event so you don’t have to set the boolean to true later on in order to play the animation once again.

Edit : i just realized i did it wrong, i thought the problem were animations plays and doesn’t stop :skull:

1 Like

its okay, thanks for trying to help anyway lol the issue is that the animation randomly plays or doesnt play

1 Like

it looks like im not the only one with this issue, i found two posts one on reddit and one on devforum with the same issue

3 Likes

how about stopping other animations

for i,v in pairs(c.Humanoid:GetPlayingAnimationTracks()) 
	if v.Animation.AnimationId ~= animation.AnimationId then
v:Stop()
 end
end
1 Like

hey, i doubt that will work since the animation is for a model of hands which play only one animation, and not a npc / character but ill try

where in the script would i place this? before playing the animation?

1 Like

yes that would be fine to put it there.

sadly it didnt fix it, still randomly plays / doesnt play thanks for the effort though

After a couple of days, the animations randomly fixed themselves what is roblox up to bruh.
Update: after like 2 days the animations broke again randomly its a studio bug i think

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