Get coordinates of player and save to variable

Hello, I'm trying to make an event that causes an object to spawn on top of the player. I believe the best way to manage that for my purposes would be to make a command that takes the player's current coordinates and saves them to two variables (one for x and one for y). I'm not experienced with scripting in RPG Maker yet, so I'm not sure how to start with this. Could someone help me out?
no need for any script
playerx.png
Code:
$game_variables[1] = $game_player.x
$game_variables[2] = $game_player.y

Just replace 1 and 2 with the positions you might prefer.

Original thread: https://forums.rpgmakerweb.com/threads/get-coordinates-of-player-and-save-to-variable.131138/