Instantiate prefab at current location

I have a player when he taps on a location it instantiate an object. I am able to instantiate the object but it creates the object in a different location not where the player is. Following is part of my script:

var currentPosition =  GameObject.Find("Player");
Debug.Log("Position" + currentPosition.transform.position);
var create = Instantiate(gold, currentPosition.transform.position, Quaternion.identity); 
//also tried
		Instantiate(gold, transform.position, Quaternion.identity);

When i do the debug, the position is not the player’s location. How do I refer to the current location of the player?
As far as I know, transform.position tells where your location.

Assuming you have one (and only one) game object in your scene named ‘Player’, then I don’t see any problem with what you’re doing there. If it’s not working, I would guess that the problem is elsewhere.

What object is the script attached to? Is it attached to the ‘player’ object?

Yes I have only one object named Player. The script is attached to the Player and this script is the PlayerRelativeControl which i amended to my needs.
I have notice something, when the gold is created the position is (7.7, 4.1, -25.1) and my player’s position is (7.7, 3.1, -15) but the actual gold on the scene is way far away from my player, when i create a cube according to the gold location its actually beside my player. What went wrong here? Is this something to do with the global and local location?

Thank you.

If the script is attached to the ‘player’ object, then you don’t need to find it using GameObject.Find(). Instead, you can just access the transform directly as in the last line of code in your example (after ‘//also tried’).

Is there any other relevant code before or after the code you posted? Can you post the code where you’re printing out the coordinates for the various objects?

Yes I am using the second code, that when i realize the location the gold appeared. Following is the script:
Its in the update function:

if ( rotateJoystick.tapCount >= 1 )
	  {
			var count = Input.touchCount;
			for(var i : int = 0;i < count; i++)
		        {
			     var touch : Touch = Input.GetTouch(i);
                        
                              if( animationTarget.IsPlaying( "idle front" )) 
			      {
				    animationTarget.Play("dig front");
				    animationTarget.CrossFade( "dig front" );
				    Instantiate(gold, transform.position, Quaternion.identity);
				    Debug.Log("Position" + transform.position);
			      }
                        }
        }

For the gold appeared on the scene I check the position from the inspector.

I am still having the same issue… The prefab gold is appearing in a different place but as per the editor’s position the location is in the same place.

	var goldAppear = Instantiate(gold,transform.position,Quaternion.identity);
	Debug.Log("Gold" + goldAppear.transform.position + "Player" + transform.position);
// this is the result Gold(7.6, 2.5, -25.4)Player(7.6, 2.5, -25.4)

Why is the gold appearing somewhere else in the scene. Is there any changes I need to make or am I missing something. Please guide…
Thank you…

Does the gold have a (non-trigger) collider associated with it? Is it getting ‘pushed out of the way’ by the player after being instantiated?

No the gold doesn’t have any collider it is just a gameobject with animation. It only should appear at the user’s location after instantiated. There is no other action’s at the moment attached to the script.

Is the gold object a top-level object in the hierarchy? Or is it a child object? If it’s a top-level object, does it have any child objects?

The gold is not in the hierarchy, its a prefab in the project.

Edit:
In my Player script I initialize it as var gold:Transform;
I drag the prefab into the inspector of the player.

Right, but the clone that’s instantiated is an object in the hierarchy, and that’s the object I’m asking about.

The point of my question is to acquire more information about the context. It’s not clear from what you’ve posted so far (at least not to me) why the ‘gold’ object would appear to change position after it’s instantiated, so it seems to me that there must be something else going on - something we don’t know about - that’s causing that to happen (or to appear to happen).

When its cloned, its a top level object in the hierarchy. It is not child object.
What is happening in my full script is when my player press the action button down once, it plays an animation, after the animation which i instantiate the gold to appear. Then the player goes back to idle animation. That is what i have scripted so far.
After this, I need the player to collect the gold and place it in the inventory. But I cant seem to past my first objective to make the gold appear beside the player.
I only have two scripts for the players movement and animation. Both that script is attached only to the player.
If there something happening is there a way I can check on the editor?

[Solved]
The issue was with my gold object, there was invisible space around the object that made it to appear at a corner of the scene.
Thanks for your time Jesse.