Help with data stores

I want to make a script that saves and loads. here is the script


but whenever i try use it it doesn’t work.
when i do print(data[1]) it shows the correct data but when i try make it equal to my leader stats it doesn’t work. Any ideas why?

When you do

local coins = player.leaderstats.coins.Value

the value stored in coins is the value of the leaderstat at that current moment, so say player.leaderstats.coins.Value = 36, you’re essentially doing local coins = 36.

In order to be able to edit the leaderstat like this, you need to edit its value each time instead like this:

local coins = player.leaderstats.coins
coins.Value = data[1]

This should hopefully work :slight_smile:

thanks so much!!!
i spent so much time troubleshooting that script.

image
You haven’t created the values using Instance.new