How to reset a gameobject's transform?

So I am making an endless runner using an asset I got on the store, works well but the only problem is that it recycles the game pieces rather than re-instantiating them. In my game you drive around and his objects like street lamps, and after you hit one and the platform gets recycled, the lamppost is already on the ground the next time you come around to the same platform. I wrote a script to put on any intractable objects but it does not seem to work, I will link it below though. Any help is appreciated thanks for your time!

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

public class resetPrefab : MonoBehaviour {
	public Transform originalPosition;

	// Use this for initialization
	void Start () {
		
	}
	
	// Update is called once per frame
	void Update () {
		if (this.gameObject.activeInHierarchy) {
			Debug.Log ("reset");
			Vector3 currentPosition = new Vector3 (transform.position.x, transform.position.y, transform.position.z);
			Quaternion currentRotation = new Quaternion (transform.rotation.x, transform.rotation.y, transform.rotation.z, 0);
			currentPosition = originalPosition.position;
			currentRotation = originalPosition.rotation;
		}
	}
}

It looks like there isn’t anything reassigning the objects position but instead saving it’s position.

The line below is making a new position of the objects current position or rotation but rather saving the positions then doing nothing with them.

Vector3 currentPosition = new Vector3 (transform.position.x, transform.position.y, transform.position.z);

The line below is changing what “currentPosition” contains to what the “originalPosition”'s position is.

currentPosition = originalPosition.position;

Below is a solution and will change the position of the current object to have the same position as the prefab.

transform.position = originalPosition.position;

Likewise for the rotation
transform.rotation = originalPosition.rotation;

Final:

 if (this.gameObject.activeInHierarchy) {
     Debug.Log ("reset");
     transform.position = originalPosition.position;
     transform.rotation = originalPosition.rotation;
 }

Two things you’re doing wrong here:

Firstly, linking a Transform to your script like that isn’t really what you want to do here because when you get the position from that Transform, it’ll give you the current position of whichever object owns that Transform. You COULD make a second gameobject that never moves and get its transform this way, but that’s doing more work than you need to.

Secondly, I’m not 100% certain what you’re trying to do at the end there, but setting the local variables “currentPosition” and “currentRotation” like that won’t affect your gameobject’s position and rotation at all, that’s now how C# works. You have to set your gameobject’s transform’s position and rotation.

This is how I would do what you’re trying to do:

private Vector3 originalPosition;
private Quaternion originalRotation;

void Awake()
{
	this.originalPosition = this.transform.position;
	this.originalRotation = this.transform.rotation;
}

// call this function to reset this script's object's position and rotation
public void resetTransform()
{
	this.transform.position = this.originalPosition;
	this.transform.rotation = this.originalRotation;
}