|
| 31 May 2014 05:42 PM |
It has no error. It just does not load. What did i do wrong?
local DataStore = Game:GetService("DataStoreService"):GetDataStore("Stats")
Game.Players.PlayerRemoving:connect(function(Player1) Player1:WaitForDataReady() local key = "user_" .. Player1.userId DataStore:UpdateAsync(key, function(oldValue) local Data1 = Player1:WaitForChild("leaderstats"):GetChildren() for i= 1,#Data1 do Data1:SetAsync(Data1[i].Name, Data1[i].Value) end end) Game.Players.PlayerRemoving:connect(function(Player2) Player2:WaitForDataReady() local key = "user_"..Player2.userId if DataStore:GetAsync(key) ~= nil then local Data2 = Player2:WaitForChild("leaderstats"):GetChildren() for i = 1, #Data2 do Data2:GetAsync(Data2[i].Name) end end end) end) |
|
|
| Report Abuse |
|
|
|
| 31 May 2014 05:43 PM |
| You're updating the async when they enter. You cannot update an async before you set the async. |
|
|
| Report Abuse |
|
|
|
| 31 May 2014 05:45 PM |
| It's just that? It's all fine after i use SetAsync? |
|
|
| Report Abuse |
|
|
|
| 31 May 2014 05:53 PM |
| It made no difference. Still does the same thing. Anyone? |
|
|
| Report Abuse |
|
|
Usering
|
  |
| Joined: 18 Aug 2012 |
| Total Posts: 10281 |
|
|
| 31 May 2014 06:03 PM |
You have to use the Increment, Set, and Get methods on GlobalDataStore, not get GetDataStore. Change DataStore to game:GetService("DataStoreService"):GetGlobalDataStore().
if that doesn't help, try finding the error |
|
|
| Report Abuse |
|
|
|
| 31 May 2014 06:11 PM |
| I'm actually trying to save the stats, tried that nothing. Same thing. Anyone else? |
|
|
| Report Abuse |
|
|
Usering
|
  |
| Joined: 18 Aug 2012 |
| Total Posts: 10281 |
|
|
| 31 May 2014 06:12 PM |
Did you not read what I posted? I literally gave you the answer.
local DataStore = Game:GetService("DataStoreService"):GetDataStore("Stats")
to
local DataStore = Game:GetService("DataStoreService"):GetGlobalDataStore() |
|
|
| Report Abuse |
|
|
| |
|
Usering
|
  |
| Joined: 18 Aug 2012 |
| Total Posts: 10281 |
|
|
| 31 May 2014 06:18 PM |
1. You don't need to call Player:WaitForDataReady() for DataStore. DataStore is always ready to save and retrieve, since it does not save to the player. 2. You're trying to call SetAsync on GetChildren() when you should set it on DataStore "Data1 = Player1:WaitForChild("leaderstats"):GetChildren()" |
|
|
| Report Abuse |
|
|
|
| 31 May 2014 06:28 PM |
So if i set "Data1 = Player1:WaitForChild("leaderstats"):GetChildren()" to "DataStore = Player1:WaitForChild("leaderstats"):GetChildren()"
what should Data1 equal?
for i= 1,#Data1 do Data1:SetAsync(Data1[i].Name, Data1[i].Value) end end) end) |
|
|
| Report Abuse |
|
|
| |
|
Usering
|
  |
| Joined: 18 Aug 2012 |
| Total Posts: 10281 |
|
|
| 31 May 2014 06:52 PM |
| You should always set DataStore stuff to your DataStore variable. |
|
|
| Report Abuse |
|
|
|
| 31 May 2014 07:09 PM |
| Why does it not load. I did what you said. |
|
|
| Report Abuse |
|
|
| |
|
| |
|