So I create AnimTrack, and play it on the player, that works fine. Then the irrelevant code executes, a and b print, but the player continues to play the animation track. This is all executed on the server.
AnimTrack = Humanoid:LoadAnimation(Rogue:GetAsset("Animations.Character_Fire"))--:Play()
--bleep bloop irrelevant code
Because of the delay before the code inside spawn() executes, you’re calling Stop() and Destroy() before LoadAnimation() and Play(). (This assumes your irrelevant code really is irrelevant and not yielding)
The irrelevant code might’ve been relevant then I guess, hadn’t thought of that. It yields the code for 5 seconds.
There were no errors outputted, and a and b both print.
local DamageToDeal = 50
local TimeToDamage = 5
local Steps = 50
local DamagePerStep = DamageToDeal / Steps
local TimePerStep = TimeToDamage / Steps
for i = 1, Steps do
Humanoid.Health = Humanoid.Health - DamagePerStep
if Humanoid.Health <= 0 then
That code works for me as long as the wait(TimePerStep) executes once. If the humanoid dies on the first iteration of the for loop though, it’s going to error because it will try to call Stop() before AnimTrack has been assigned to (it will still be nil).
If it doesn’t work for you still, maybe print out something other than ‘a’, like the value of AnimTrack or AnimTrack.IsPlaying, etc? Is this spawned function the only place in the whole script where AnimTrack is assigned to? And if so, is it definitely happening only once? If you’re loading and starting that animation more than once, while it’s still playing, that could be a problem.