The datastore wont change it's value to the leaderstats value, why?
I was using a bunch of different datastore scripts, none of them worked and I was stumped, I decided to use the Alvinblox one and it didn't work, I went into the console and saw that the datastore was set to the right value, but it wasn't changing the leaderstats to that value.
01 | local DataStoreService = game:GetService( "DataStoreService" ) |
03 | local myDataStore = DataStoreService:GetDataStore( "myDataStore" ) |
05 | game.Players.PlayerAdded:Connect( function (player) |
06 | local leaderstats = Instance.new( "Folder" ) |
07 | leaderstats.Name = "leaderstats" |
08 | leaderstats.Parent = player |
10 | local cash = Instance.new( "IntValue" ) |
11 | cash.Name = "Dollaroos" |
12 | cash.Parent = leaderstats |
15 | local success, errormessage = pcall ( function () |
16 | data = myDataStore:GetAsync(player.UserId.. "-cash" ) |
22 | print ( "There was an issue saving your data" ) |
27 | game.Players.PlayerRemoving:Connect( function (player) |
29 | local success, errormessage = pcall ( function () |
30 | myDataStore:SetAsync(player.UserId.. "-cash" ,player.leaderstats.Dollaroos.Value) |
34 | print ( "Player Data Successfully Saved!" ) |
36 | print ( "There was an error when saving data" ) |
all I did was modify his script because I didn't want to break it.