I want to get the transform of the object i hit and then instantiate anoter above.
Unity does not provide a straightforward way to grab a game object out of a raycast hit.
The RaycastHit object contains a reference to the Collider that was hit. That collider is the component and like any component, it has a reference to the transform of the game object.
public class RaycastExample : MonoBehaviour
{
void FixedUpdate()
{
RaycastHit hit;
if (Physics.Raycast(transform.position, -Vector3.up, out hit))
print("Found an object : " + hit..collider.transform);
}
}