The value in the leaderboard changes, but the data is not saved. Does anyone know this solution

hello? I have a question regarding the game data storage system.
I am creating a seed exchange system using gui buttons.
However, the exchanged values ​​are visible in the gui connected to the leaderboard, but the data is not saved and the changed values ​​are not applied during the game. Can you tell me the answer to this question?
All values ​​previously obtained using the tool will be saved.

This is the value obtained using the tool.


The values ​​of seeds and sprout were exchanged using the gui button.

However, when you play again, only the values ​​obtained using the tool will be saved.

============================================================


This is my player data script

====================================================

This is the exchange system script

I am a beginner and I also wrote the player data script using YouTube. Please help me…

remember to respect the timing limits of dataStore Services.
I dont know if youre updating the value of a datasore everytime you make an exchange. this is verry bad for datastore.
I whould recomend handlind exchages in the server and have a table that stores all the data and ONLY save the data when a player LEAVES THE GAME. this way you can still make exchanges but they will be saved to a data store when a player leaves the game

EXAMPLE:

player bought a seed and exchanged it .

save that value in a table and update (like leaderboards and uis)

when player leaves the game call data store service to save that table.

Thank you. Could you please show me an example of your code? I lack the ability to write code on my own…

TESTN1.rbxl (67.9 KB)

dont forget to play the game in roblox app NOT in studios and dont forget to enable API access to studios

You are so kind. Thank you. However, it did not solve the storage problem of the exchange system. sorry.

i tested the game and it saved my data. i dont know what is going wrong

local scripts can not change stuff on the server. so localy the values are updated but the server sees the original values. fire a remote event when you want to update the leaderboard and change it server side.

I used the script you sent. The data values ​​obtained by stepping on the part are saved, but when applied to the exchange system I created, the changed values ​​are not saved. Sorry.

What parts can I modify or add to the script? I would appreciate your help.