generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Datastores not saving

Previous Thread :: Next Thread 
MujahidArno is not online. MujahidArno
Joined: 17 Feb 2010
Total Posts: 2893
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
MujahidArno is not online. MujahidArno
Joined: 17 Feb 2010
Total Posts: 2893
14 Nov 2016 12:33 PM
It print's Data found but not that the data was saved
Report Abuse
memorycode is not online. memorycode
Joined: 24 Sep 2011
Total Posts: 3322
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
MujahidArno is not online. MujahidArno
Joined: 17 Feb 2010
Total Posts: 2893
14 Nov 2016 12:57 PM
"Cannot store Instance in DataStore"

What can I do to fix that?
Report Abuse
MujahidArno is not online. MujahidArno
Joined: 17 Feb 2010
Total Posts: 2893
14 Nov 2016 01:45 PM
up
Report Abuse
MujahidArno is not online. MujahidArno
Joined: 17 Feb 2010
Total Posts: 2893
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
memorycode is not online. memorycode
Joined: 24 Sep 2011
Total Posts: 3322
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
memorycode is not online. memorycode
Joined: 24 Sep 2011
Total Posts: 3322
14 Nov 2016 02:30 PM
Data as in the parameter "Data", not the Data:


Report Abuse
TimeTicks is not online. 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
MujahidArno is not online. MujahidArno
Joined: 17 Feb 2010
Total Posts: 2893
14 Nov 2016 02:36 PM
Data is a folder containing the StringVaues, NumberValues etc
Report Abuse
memorycode is not online. memorycode
Joined: 24 Sep 2011
Total Posts: 3322
14 Nov 2016 02:54 PM
You can't save a folder.


Report Abuse
memorycode is not online. memorycode
Joined: 24 Sep 2011
Total Posts: 3322
14 Nov 2016 02:54 PM
Also, look more into how DataStores work. TimeTicks has a really good post.


Report Abuse
MujahidArno is not online. MujahidArno
Joined: 17 Feb 2010
Total Posts: 2893
26 Nov 2016 05:31 AM
If someone get this to work, I'm willing to pay.
Report Abuse
DevVince is not online. DevVince
Joined: 08 Nov 2008
Total Posts: 9245
26 Nov 2016 07:27 AM
Data:SetAsync('Save_'..p.userId, DataToSave)
Report Abuse
DevVince is not online. 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
MujahidArno is not online. MujahidArno
Joined: 17 Feb 2010
Total Posts: 2893
27 Nov 2016 12:41 PM
For some reason this only works 1/2 times. :(
Report Abuse
DevVince is not online. DevVince
Joined: 08 Nov 2008
Total Posts: 9245
30 Nov 2016 08:55 AM
Do you have something hogging the datastores?
Report Abuse
MujahidArno is not online. MujahidArno
Joined: 17 Feb 2010
Total Posts: 2893
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 is not online. 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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image