function AnimateLib.ConditionalOnHeartbeat(h,f,j,H)local B local u=Utils.new("\069\118\101\110\116")local F=tick()B=(game:GetService("\082\117\110\083\101\114\118\105\099\101")).Heartbeat:connect(function(j)if f()then h(j,tick()-F)else B:disconnect()u:Fire()if H then H()end end end)if j then u:wait()end end
--[[ @brief Performs an operation on heartbeat based on a condition.
     @param callback The callback function for each heartbeat step.
     @param condition The condition we should check before running callback.
     @param yield Whether this function should yield or return immediately.
--]]
function AnimateLib.ConditionalOnHeartbeat(callback, condition, yield, callbackOnComplete)
	local cxn
	local event = Utils.new("Event")
	local startTime = tick()
	cxn = game:GetService("RunService").Heartbeat:connect(function(step)
		if condition() then
			callback(step, tick() - startTime)
		else
			cxn:disconnect()
			event:Fire()
			if callbackOnComplete then
				callbackOnComplete()
			end
		end
	end)
	if yield then
		event:wait()
	end
end
