Rotate GameObject Issue

So I have a gameobject that I currently have locked onto another object. It’s setup with the following code:

var objectToFollow;

function Update () 
{
	if(gameObject.Find("localPlayer")==null)
	{}
	else
	{
		objectToFollow = GameObject.FindWithTag("Player").transform;
		transform.position = objectToFollow.TransformDirection(Vector3.forward * 4) + objectToFollow.position;
		transform.rotation = objectToFollow.rotation;
		
		//needs to be rotated by 0,-90,90
		
	}
}

So the problem I have, as seen by the comment, is that the object needs to be rotated. I’ve tried a few methods of doing this but they don’t work for a specific reason. I need the object to stay in rotation relation to the player. It currently does this with the code, but it’s facing the wrong way. I can set it up so that on start of gameplay it’s facing the right way, but if I turn it stays pointing the same direction in the world instead of continuing to point at me. This is because the object is a child of my avatar, as it needs to remain.

Any ideas?
Thanks!

Didn’t I anwser this originally? Anyway, try this:

var objectToFollow;

function Update () 
{
	if(gameObject.Find("localPlayer")==null)
	{}
	else
	{
		objectToFollow = GameObject.FindWithTag("Player").transform;
		transform.position = objectToFollow.TransformDirection(Vector3.forward * 4) + objectToFollow.position;
		transform.rotation = objectToFollow.rotation * Quaternion.Euler(0,-90,90);
	}
}