RemoteFunction automatically finish

My RemoteFunction is finishing automatically and returning nil, and don’t wait the animation stop, the script is here:

	local ATs = Animator:GetPlayingAnimationTracks()
	local Animation
	for _, v in pairs(ATs) do
		if v.Animation.AnimationId == AnimationId then
			Animation = v
		end
	end
	Animation.Stopped:Connect(function()
		return true
	end)
end

Anyone can help?

This schedules a function to be run, it doesn’t wait for it; in other words, the thread continues and the supplied callback runs asynchronously. The way you did it would also cause a memory leak!

Instead of this, you should replace that with:

Animation.Stopped:Wait()
return true

Thanks so much! The problem was solved.

1 Like

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