C# Using an object from another object

Sorry, ambiguous title. I will explain. So, I have the main camera over a plain and my “Player” resting just over the plane. What I am trying to do is create some form of a selecting mechanic. To test whether or not it has at least a little bit of functionality I tried to make a visual change happen when the “Player” is selected. Here’s the code: (Please be aware that this is clearly not all of the code)

if(hit.collider.gameObject.tag == "Player")
			selected = true; 
			gameObject.renderer.material.color = Color.blue; 

Now, what I think the problem is might be that I haven’t specified which gameObject to focus on WITHIN the if statement itself, I’ve merely done it within the parameter (). So, my question is this: How can I specify my “Player” object within the if statement (assuming that is the issue) so that the compiler knows what I’m talking about?

When you start with gameObject, it will understand that you are talking about the object that the script is attached to. You have to do:

hit.collider.gameObject.renderer.material.color = Color.blue;