How can I save leader stats data for collected presents?

So I have an obby system in my game that saves the checkpoint so when a player leaves and rejoin they’ll be back in the same spot.

I’ve added a “:gift:Presents” leaderstats value so to when a player collects the present the value goes up on the leaderstat. I was wondering how would I save that data so when a player leaves and rejoins the amount saves.

The script is below…

The image above is the script that saves my obby data but I would also like to add the ability to save my present value too for when players leave. I am not much experienced with scripting too.

I’d appreciate any help or guidance :slight_smile: Thank you

Also this is the script that makes players be able to collect the presents and add a value to the leaderstats.

Instead of

local success, errorMessage = pcall(function()
        ObbyDataStore:SetAsync(playerkey, {Stage = stage})
end)

Just do

local success, errorMessage = pcall(function()
        ObbyDataStore:SetAsync(playerkey, {Stage = stage, Rank = player.leaderstats["Presents"].Value})
end)

Make sure to add the presents emoji that you use for naming.
Also for your next post just copy your script and do ``` at the start and end of your code.

1 Like

Thnak you soo much! And i will keep that in mind for next post. I appreciate your help alot :slight_smile:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.