Dynamically adding Light component and changing its height

So i’v tried to add the component to player, because network player spawns and creates a dynamic object for player and i need to change the spotlight height but i cant understand how.

My code:
//Flashlight comp

		GameObject taskulamp = actor.GetComponent<Light>().type = LightType.Spot;
		Vector3 lightpos = new Vector3(0,5,0);
		taskulambiobjekt = transform.position = lightpos;

When you add a component to an object, it shares the same transform. If you want the light to be at a different position, it must be added to a child:

GameObject lampObj = new GameObject("Lamp"); // create the Lamp object
lampObj.transform.parent = actor.transform; // child it to the player
lampObj.transform.localPosition = new Vector3(0,5,0); // set its local position
lampObj.AddComponent<Light>(); // add a light to it
lampObj.light.type = LightType.Spot; // set the light properties
lampObj.light.range = 6.0f;