|
| 14 Nov 2016 12:30 PM |
Could you tell my why this isn't saving anny data and how I can fix it?
game.Players.PlayerRemoving:connect(function(p) print(p.Name.." has left the game #kek") local ls = p:FindFirstChild'Data' if ls then local DataToSave = {} for i,v in pairs(ls:GetChildren()) do table.insert(DataToSave, {name = v.Name, value = v.Value}) print'data found' end pcall(function() Data:SetAsync('Save_'..p.userId, Data) print(p.Name.."'s data has been saved.") end) else print'data not found' end end) |
|
|
| Report Abuse |
|
|
|
| 14 Nov 2016 12:33 PM |
| It print's Data found but not that the data was saved |
|
|
| Report Abuse |
|
|
|
| 14 Nov 2016 12:34 PM |
1) Use p.UserId 2) Remove the pcall so you can see what error it spits out
|
|
|
| Report Abuse |
|
|
|
| 14 Nov 2016 12:57 PM |
"Cannot store Instance in DataStore"
What can I do to fix that?
|
|
|
| Report Abuse |
|
|
| |
|
|
| 14 Nov 2016 01:46 PM |
game.Players.PlayerRemoving:connect(function(p) print(p.Name.." has left the game #kek") local ls = p:FindFirstChild'Data' if ls then local DataToSave = {} for i,v in pairs(ls:GetChildren()) do table.insert(DataToSave, {name = v.Name, value = v.Value}) print'data found' Data:SetAsync('Save_'..p.UserId, Data) print(p.Name.."'s data has been saved.") end else print'data not found' end end) |
|
|
| Report Abuse |
|
|
|
| 14 Nov 2016 02:30 PM |
Data:SetAsync('Save_'..p.UserId, Data)
What is Data? I don't see it defined.
Also, you may wanna store the array in JSON
|
|
|
| Report Abuse |
|
|
|
| 14 Nov 2016 02:30 PM |
Data as in the parameter "Data", not the Data:
|
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 14 Nov 2016 02:31 PM |
https://forum.roblox.com/Forum/ShowPost.aspx?PostID=201595803
|
|
|
| Report Abuse |
|
|
|
| 14 Nov 2016 02:36 PM |
| Data is a folder containing the StringVaues, NumberValues etc |
|
|
| Report Abuse |
|
|
| |
|
|
| 14 Nov 2016 02:54 PM |
Also, look more into how DataStores work. TimeTicks has a really good post.
|
|
|
| Report Abuse |
|
|
|
| 26 Nov 2016 05:31 AM |
| If someone get this to work, I'm willing to pay. |
|
|
| Report Abuse |
|
|
DevVince
|
  |
| Joined: 08 Nov 2008 |
| Total Posts: 9245 |
|
|
| 26 Nov 2016 07:27 AM |
| Data:SetAsync('Save_'..p.userId, DataToSave) |
|
|
| Report Abuse |
|
|
DevVince
|
  |
| Joined: 08 Nov 2008 |
| Total Posts: 9245 |
|
|
| 26 Nov 2016 07:33 AM |
game.Players.PlayerRemoving:connect(function(p) local ls = p:FindFirstChild'leaderstats' if ls then local DataToSave = {} for i,v in pairs(ls:GetChildren()) do table.insert(DataToSave, {name = v.Name, value = v.Value}) end pcall(function() Data:SetAsync('Save_'..p.userId, DataToSave) print(p.Name.."'s data has been saved.") end) end end) |
|
|
| Report Abuse |
|
|
|
| 27 Nov 2016 12:41 PM |
| For some reason this only works 1/2 times. :( |
|
|
| Report Abuse |
|
|
DevVince
|
  |
| Joined: 08 Nov 2008 |
| Total Posts: 9245 |
|
|
| 30 Nov 2016 08:55 AM |
| Do you have something hogging the datastores? |
|
|
| Report Abuse |
|
|
|
| 02 Dec 2016 08:38 AM |
Nothing should be interfering this script. No other data-saving scripts are being used. This script should be placed in Workspace in a server script, correct? |
|
|
| Report Abuse |
|
|
Railmints
|
  |
| Joined: 11 Aug 2014 |
| Total Posts: 272 |
|
|
| 02 Dec 2016 09:46 AM |
| Data store is unable to save INSTANCES or objects but is able to store VALUES. So for example i would be unable to datastore a custom part that i made but i would be able to save its property values in datastore. I think if you want to save instances you use data persistance, but it is deprecated. |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 02 Dec 2016 10:00 AM |
dude i gave you a complete example. what dont you understand?
https://forum.roblox.com/Forum/ShowPost.aspx?PostID=201595803
|
|
|
| Report Abuse |
|
|