Saving x and y positions

I am using a joystick in my game, and I need it to save the players location if you pause or go into the inventory or whatever, I am using this:


How could I do this? I have never done anything related to saving before and any help would be appreciated.

Are you talking about saving the data after you close the app, or just temporarily? If you want to save it after the app is closed, use saveLocalData. If you save it just while you go to a different state, set it as a global variable, then read it again.
Welcome to the forums!

Ok, but what would I save the variables value as? I tried

SaveLocalData(“object”, object.x)
SaveLocalData(“object”, object.y)

But that doesn’t work, I guess I’m naming something wrong but what would that be?

Use saveLocalData with a lowercase “s”. When you want to read it, use readLocalData(key). BTW, if you want to notify me when you’re talking to me, use @Zoyt, in case you didn’t know.

saveLocalData(‘objectX’, object.x)
saveLocalData(‘objectY’, object.y)

Local savedX = readLocalData(‘objectX’)
Local savedY = readLocalData(‘objectY’)