I have a tap that sounds like it is coming from the top would it be the cam or the valves it hasn't lost power or changed idle position what is the best way to find what it is
More information on the Ranger would help us give you more specific information on the problem.
The most common noise from under the valve covers would be "tapping" from excessive valve clearance.
This can be caused by things like loose or broken rocker arms or cam followers, bad hydraulic lifters, worn camshaft, bent push rod (if applicable), or a broken valve spring. Aerated oil from overfilling the crank case, and/or low oil pressure, can cause all of the valves to make noise.
If only one valve is making the noise, and you know your way around the vehicle, pull the valve cover off from the side making the noise and visually inspect while running the engine at idle. But watch out for squirting or splashing oil from rockers, valve followers, or cam shaft, depending on the year and engine.
Your observation is important. If the valve barely moves then it's a significant failure which is usually pretty obvious once you're in there. If it's just noisy, sometimes an adjustment will do the trick.