Weird bug with animations

I want to figure out what’s causing the problem I’m having

basically, I am making a turn based combat game, and right now, after the first battle, when the enemy attacks the player, it takes a while till the animation starts to play as I have the moment the player gets damaged on an animation event. It only happens after the first enemy but its not always consistent, sometimes the animation plays when its supposed to, sometimes there’s like up to a 20 second delay.

in the clip I show the battle sequence for the first and second enemy, between the cuts are me attacking. you can see as the second enemy attacks more, the delay between his animation playing is getting longer.

I’ve at least maybe ruled out a possible memory leak causing the problem as I’ve tested it with the dev log menu open to see the memory usage and it stayed consistent around 1400 and doesn’t really change between battles as shown in the clip below.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

below is the code for the animation and the damaging in the enemy script

local punchAnim = "rbxassetid://18262149195"

local baseATKDmg : IntValue = enemyHrp.Parent:WaitForChild("baseATKDmg")

local animator : Animator = enemyHum:WaitForChild("Animator")
local animation = Instance.new("Animation")
animation.AnimationId = punchAnim

local animTrack = animator:LoadAnimation(animation)

enemyHum:MoveTo(fightigA1.enemyPlace2Attack.Position)

enemyHum.MoveToFinished:Connect(function()
	if attackDone == false then
		attackDone = true
		animTrack:Play()
				
		task.wait(0.5)

		plrHum:TakeDamage(dmg)

        -- fires to the client to show the damage that was dealt and shows the health bar
		dmgEvent:FireClient(player, dmg, plrHum, "basic", true)

		animTrack.Ended:Connect(function()
			enemyHum.WalkSpeed = 30
			enemyHum:MoveTo(fightigA1.enemySpawn.Position)
					
			task.wait(1)

			-- fires to the combat gui local script to show the fighting gui as the enemy attack is done		
			combatEvent:FireClient(player, "enemyATKdone")		
		end)		
	end	
end)
attackDone = false

so I just need an opinion or a clue as to what could be causing this problem as I’m really not sure at all as to why this is happening but maybe it might be due to one of the errors shown in the second clip where it says “Property “Animator.EvaluationThrottled” is not currently enabled. (x7)”

1 Like

need a bit of context to understand when this script is running.

of course when the script is created it’s run, but how are you able to repeat that same set of code? are you just making the enemy MoveTo again in another script so that the event runs again? or are you disabling/enabling the script again so that it starts over?

Don’t really know why this is but try setting the animation priority to Action, then re-publishing it.

ServerSided animations are tend to lag, Replicate them to a local script

this is the process for each attack cycle:

  1. player does an action to cause the end of the players turn
  2. an event is passed to the enemy script to do its attack
  3. the enemies MoveTo happens only once its the end of the players turn
  4. when the enemy reaches the specific point for it to attack it plays the attack animation
  5. when the anim event for the time to damage is reached it does all the processes to deal damage and show the damage
  6. then the enemy does another MoveTo to get back to its base position and then its the players turn again and the enemy script is then dormant till the event is passed again

this allows the same code to be repeated but i dont disable/enable the enemy script