Emotes overlap problem

Does anyone know why my emotes are overlapping and not stopping

function PlayPose(char, id)
local finished = false
local ct = os.time()
print(‘playing pose’)
local anim = Instance.new(‘Animation’, char)
anim.AnimationId = id
anim = char:WaitForChild(“Humanoid”):WaitForChild(“Animator”):LoadAnimation(anim)
anim.Looped = false
anim:Play()
coroutine.wrap(function()
anim.Ended:Wait()
print(‘physically ended’)
anim:Stop()
finished = true
end)()
repeat task.wait() until (os.time()-ct >= GameHandler.PoseCutoffTime) or finished
anim:Stop()
anim:Destroy()
print(‘over’)
for i,v in char[‘Humanoid’]:GetPlayingAnimationTracks() do
v:Stop()
end
end

2 Likes

Anyone know any fixes? It’s still happening or any ideas around it?

Hard to read the code so I can’t really tell. Maybe something to do with the coroutine? Also post this in #help-and-feedback:scripting-support instead of #help-and-feedback:creations-feedback so people looking to solve such issues know where to find this topic.