|
| 18 Jul 2014 10:00 AM |
I have been having issues with making a functional data store script. This script runs without errors, yet when I join the game the data has not been saved. The "mapNumb" referenced is an IntValue inside of starterpack.
game.Players.PlayerRemoving:connect(function(player) local datastore = game:GetService("DataStoreService"):GetDataStore("MapStats") player:WaitForDataReady() wait(2) mapDist = player.Backpack:FindFirstChild("mapNumb").Value datastore:SetAsync(player.Name, mapDist) end)
game.Players.PlayerAdded:connect(function(player) local datastore = game:GetService("DataStoreService"):GetDataStore("MapStats") repeat wait() until player.Character player:waitForDataReady() wait(2) mapDist2 = player.Backpack:FindFirstChild("mapNumb").Value datastore:SetAsync(player.Name, mapDist2) player.Backpack.mapNumb.Value = datastore:GetAsync(player.Name) end)
game.OnClose = function() wait(3) end |
|
|
| Report Abuse |
|
|
|
| 18 Jul 2014 10:06 AM |
| I've made four separate posts asking this same exact question, and I still have not received help! |
|
|
| Report Abuse |
|
|
|
| 18 Jul 2014 10:08 AM |
Don't use WaitForDataReady, that's for something else.
datastore:SetAsync(player.Name, mapDist2)
You are just overriding the data, that's why. |
|
|
| Report Abuse |
|
|
|
| 18 Jul 2014 10:08 AM |
| Does anyone even know how to correctly use Data Store? This is ridiculous. |
|
|
| Report Abuse |
|
|
| |
|
|
| 18 Jul 2014 10:10 AM |
I am overriding the data with the updated number, or at the very least I SHOULD be.
I join my game and the value of mapNumb is 1.
I change the value of mapNumb to 2, verify that it is actually 2, then leave the game
I join the game and the value of mapNumb is 1 again. |
|
|
| Report Abuse |
|
|
|
| 18 Jul 2014 10:13 AM |
| You're not setting MapNumb... |
|
|
| Report Abuse |
|
|
|
| 18 Jul 2014 10:15 AM |
datastore:SetAsync(player.Name, mapDist2) player.Backpack.mapNumb.Value = datastore:GetAsync(player.Name)
*New IntValue has value 0 *Sets DataStore to 0 *Loads 0 into the IntValue |
|
|
| Report Abuse |
|
|
|
| 18 Jul 2014 10:16 AM |
| Also, every time they reset they will lose all their stats. |
|
|
| Report Abuse |
|
|
| |
|
|
| 18 Jul 2014 10:20 AM |
| What do you suggest I do to fix it, then? |
|
|
| Report Abuse |
|
|