Value wont change to saved value [Solved]

  1. What do you want to achieve?
    I want to load saved values to existing IntValues

  2. What is the issue?
    the saved value wont set to any of the IntValues

	if success then
		print(data)
		smoresEaten = data.Smores.Value
		TotalCash = player.PlayerAssets.TotalCash.Value
		TotalWins = player.PlayerAssets.TotalWins.Value
		print(playerUserId.."'s data loaded")
	end
local data = {
	smores = player.PlayerAssets.SmoresEaten.Value;
	cash = player.PlayerAssets.TotalCash.Value;
	wins = player.PlayerAssets.TotalWins.Value;
}

The data loads and passes through just fine, it just wont work when its called to be set

2 Likes

This probably won’t work but try adding game:BindToClose() at the very end of the script.

In here you are making a table with keys, and to each key you are assigning your intvalues

Assigning from dictionary to int values happens here, but that is not how you read values from dictionaries.

Do this

smoresEaten = data[smores]

and i dont really understand what are you doing with
TotalCash = player.PlayerAssets.TotalCash.Value

whatever it is, player.PlayerAssets.TotalCash.Value is definitely not the data saved in your datastore

smoresEaten = data.Smores.Value
TotalCash = player.PlayerAssets.TotalCash.Value
TotalWins = player.PlayerAssets.TotalWins.Value

You’re just assigning the loaded values to variables, if you want to store them inside the value instances then you’ll need to index their “Value” properties.

TotalCash.Value
TotalWins.Value
SmoresEaten.Value

1 Like