how to save a player's location ?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By amdeus

i’m trying to save a 3d player’s location by making him touch a save point within a game and then load it again from where it was .
but i don’t know how to find the player’s coordinates ( x ,y ,z ) to save it .
i watched in youtube and i tried with this code :

i think the error in position

to save :

var game_data = { }
var x = Position3D

func _ready():

func _save_data():
var file =, File.WRITE)

to load :

var file =
if not file.file_exists(save_file):
game_data = {

		x = Position3D
	_save_data(), file.READ)
game_data = file.get_var()

if he touch the save point , it will turn it into a scene " save a game "
there are two buttons yes and no
what i do in the yes button?

please help

:bust_in_silhouette: Reply From: Gluon

The ways you get position in godot are for 3D


for anyone looking this up in the future the equivalent for 2D is


thanks but didn’t know how used it

amdeus | 2022-05-23 10:09

i wont to store it’s value inside a var and save it

amdeus | 2022-05-23 10:12