function task.start(H,r) end function task.finish(H,r) end function task.run(H,r)if r.DebounceTable.Attacking==true and time()<r.DebounceTable.lastAttackTime+r.DebounceTable.currentAttackDuration then r.DebounceTable.Attacking=true H:running()return else r.DebounceTable.CanMove=true r.DebounceTable.Attacking=false end local o,S=r:GetBestAttack()if(r.Model.HumanoidRootPart.Position-r.currentTarget.HumanoidRootPart.Position).magnitude<r.MaxAttackRange and o then if o then o=require(AttacksFolder[o])r.DebounceTable.currentAttackDuration=o.Duration end r.DebounceTable.lastAttackTime=time()r.DebounceTable.CanMove=false r.DebounceTable.Attacking=true if o then local H,S=pcall(function()o.Attack(r)end)if not H then warn(S)end end H:running()return end H:success()end return task
-- Any arguments passed into Tree:run() can be received after the first parameter, obj
-- Example: Tree:run(deltaTime) - > task:start(obj,deltaTime)

function task:start(obj)
	--[[
		(optional) this function is called directly before the run method
  		is called. It allows you to setup things before starting to run
  		Beware: if task is resumed after calling running(), start is not called.
	--]]
end
function task:finish(obj)
	--[[
		(optional) this function is called directly after the run method
		is completed with either success() or fail(). It allows you to clean up
		things, after you run the task.
	--]]
end
function task:run(obj)
	--[[
		This is the meat of your task. The run method does everything you want it to do.
			
  	 	Finish it with one of these method calls:
  		success() - The task did run successfully
  		fail()    - The task did fail
  		running() - The task is still running and will be called directly from parent node
	--]]
	if
		obj.DebounceTable.Attacking == true
		and time() < (obj.DebounceTable.lastAttackTime + obj.DebounceTable.currentAttackDuration)
	then
		obj.DebounceTable.Attacking = true
		self:running()
		return
	else
		obj.DebounceTable.CanMove = true
		obj.DebounceTable.Attacking = false
	end
	local BestAttack, range = obj:GetBestAttack()
	if
		(obj.Model.HumanoidRootPart.Position - obj.currentTarget.HumanoidRootPart.Position).magnitude
			< obj.MaxAttackRange
		and BestAttack
	then
		if BestAttack then
			BestAttack = require(AttacksFolder[BestAttack])
			obj.DebounceTable.currentAttackDuration = BestAttack.Duration
		end

		obj.DebounceTable.lastAttackTime = time()
		obj.DebounceTable.CanMove = false
		obj.DebounceTable.Attacking = true

		if BestAttack then
			local success, _error = pcall(function()
				BestAttack.Attack(obj)
			end)
			if not success then
				warn(_error)
			end
		end
		self:running()
		return
		--local AttackModule =
	end

	self:success()
end
return task
