Best way to Store players XP data

I’m creating a level system, the way its set up has the player lose all xp on death, which i dont want, this is a result of the player having their xp stat parented to their character

That being said, how can i prevent the XP value being lost on death, and how can i store it on DataStores without it saving every single time it changes, i feel like that would cause issues

just save the value on the player itself, and you’re right about the issues it would cause saving the value every time it changes. Instead, it can be saved using the PlayerRemoving event on a server script, so only when the player clicks “Leave game” it would save it.

1 Like

Have a folder with the name “leaderstats” (this will display the stats in the playerlist) or “data”. You can store XP there.

When the player leaves, the XP saves. When the player joins, if there is any data, the data is sent to the XP value in the folder.

I recommend reading this detailed tutorial on datastore in roblox, by @iFlameyz : Datastore tutorial for beginners

1 Like