Escaping coroutine and send return in function

I just tried to return detected part but can’t because of coroutine is blocking it. Is it possible to return value after coroutine is end but it should not pause main line.

local function hitbox(param)
							local hitResult = nil
							local hitEnded = false
							if humanoid.status.Value ~= "stun" then
								coroutine.wrap(function()
									local hitable = true
									coroutine.wrap(function()
										wait(param.hitTime)
										hitable = false
									end)()

									local immune = {player.Character}
									while hitable == true and humanoid.status.Value ~= "stun" do
										hitResult = hitCalculate(param, immune)
										if hitResult then
											print(hitResult)
											break
										end
										game:GetService("RunService").Heartbeat:wait()
									end
									immune = {}
									hitEnded = true
								end)()
							end
							if param.retTarget == true then
								coroutine.wrap(function() --problem is here
									while hitResult == nil and hitEnded == false do
										game:GetService("RunService").Heartbeat:wait()
									end
									if hitResult then
										return hitResult --even if I return it will not return to main line
									end
								end)()
							end
						end

return the result after the coroutine.wrap

result is nil since hitbox didn’t detect hitbox at first. I need it to wait until result is not nil and then return result. but it’s hard to do because I don’t want to pause main line, so I need to use coroutine but you can’t return result if you’re in coroutine. that’s the problem

local function hitbox(param)
	local hitResult = nil
	local hitEnded = false
	if humanoid.status.Value ~= "stun" then
		coroutine.wrap(function()
			local hitable = true
			coroutine.wrap(function()
				wait(param.hitTime)
				hitable = false
			end)()

			local immune = {player.Character}
			while hitable == true and humanoid.status.Value ~= "stun" do
				hitResult = hitCalculate(param, immune)
				if hitResult then
					print(hitResult)
					break
				end
				game:GetService("RunService").Heartbeat:wait()
			end
			immune = {}
			hitEnded = true
		end)()
	end
	if param.retTarget == true then
		coroutine.wrap(function() --problem is here
			while hitResult == nil and hitEnded == false do
				game:GetService("RunService").Heartbeat:wait()
			end
		end)()
	end
	if hitResult then
		return hitResult --even if I return it will not return to main line
	end
end

Return it outside of any running coroutine, like in the above.