Help with Overlapping Animation

Hello! I’ll make this quick and simple:

  • I have an emote system that lets the player pick from a long table of self-acquired emotes
  • When they press the button holding an emote, they play an animation
  • The problem is sometimes, an Animation may overlap with another if you do it quick enough

SCRIPT:

btn.Interact.Activated:Connect(function()
	holder.Visible = false
	if loadedAnim.IsPlaying then
		loadedAnim:Stop() --this stops any current animations, but sometimes it just doesn't work
	else
		for i, playingEmote in pairs(animateEmotes) do
			playingEmote:Stop() --this gets any emotes that are in 'animateEmotes' and stops them
			table.remove(animateEmotes, i)
		end

		loadedAnim:Play()
		table.insert(animateEmotes, loadedAnim) --this adds the current 'loadedAnim' to the table
	end
end)

What can I do/add to stop the previous animation, guaranteed?

1 Like