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 » Scripting Helpers
Home Search
 

Re: data store not working

Previous Thread :: Next Thread 
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
26 Jul 2014 10:27 PM
supposed to save a string value. does nothing. only output are the prints


Game.Players.PlayerRemoving:connect(function(Play1)
local Data2 = Game:GetService("DataStoreService"):GetDataStore(Play1.userId);
for load3, load4 in pairs(Play1.Save:GetChildren()) do
load4.Value = Data2:GetAsync(load4.Name);
end
print("saved");
end)
Game.Players.PlayerAdded:connect(function(Play2)
local Data1 = Game:GetService("DataStoreService"):GetDataStore(Play2.userId);
Play2:WaitForChild("Save") wait(1);
for load, load2 in pairs(Play2.Save:GetChildren()) do
Data1:SetAsync(load2.Name, load2.Value);
end
print("LOADED");
end)
Report Abuse
flatline115 is not online. flatline115
Joined: 29 Jul 2013
Total Posts: 7826
26 Jul 2014 10:27 PM
Output: ?
Report Abuse
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
26 Jul 2014 10:29 PM
"only output are the prints"
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
26 Jul 2014 10:30 PM
Loading at disconnect and saving on connect.
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
26 Jul 2014 10:31 PM
Also, you are using DataStores wrong.

Put everything into a table then save the table.
Report Abuse
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
26 Jul 2014 10:31 PM
so is that my error, or is that what I'm supposed to do?
Report Abuse
flatline115 is not online. flatline115
Joined: 29 Jul 2013
Total Posts: 7826
26 Jul 2014 10:32 PM
The best thing I can make out is that you're not setting the values, leading to nothing being saved.
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
26 Jul 2014 10:32 PM
Load on connect and save on disconnect.
Report Abuse
flatline115 is not online. flatline115
Joined: 29 Jul 2013
Total Posts: 7826
26 Jul 2014 10:33 PM
Also, you are using DataStores wrong.

Put everything into a table then save the table.
-------------
If the table is exceptionally long this is not always the best way to do something especially if you want to write reference material to use the table later.
Report Abuse
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
26 Jul 2014 10:34 PM
Can you give an example how how to put it in a table? None of the tutorials use tables
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
26 Jul 2014 10:34 PM
Well, you need to apply common sense to avoid the really quite high limit, but yeah.
Report Abuse
Calidum is not online. Calidum
Joined: 16 Sep 2009
Total Posts: 6060
26 Jul 2014 10:34 PM
Have you tried turning it on and off yet


Goodness Gracious that Booty is Spacious!
Report Abuse
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
26 Jul 2014 10:37 PM
Bump.
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
26 Jul 2014 10:37 PM
Already told you what to do. Save on disconnect and load on connect.
Report Abuse
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
26 Jul 2014 10:39 PM
Uhh.. That;s what I did in the script and it didn't work. And obviously if you see that I'm having trouble already doing so, why would you tell me to do that as if I have full knowledge of data store
Report Abuse
flatline115 is not online. flatline115
Joined: 29 Jul 2013
Total Posts: 7826
26 Jul 2014 10:40 PM
Can you give an example how how to put it in a table? None of the tutorials use tables
----------
example:

data = game:GetService("DataStoreService"):GetGlobalDataStore()
create = function(instant, parent, name)
thing = Instance.new(instant, parent)
thing.Parent = parent
end

game.Players.PlayerAdded:connect(function(player)
__random = {"1", "2", "3", "4", "5"}
__save = {}
item = Instance.new("StringValue", player)
item.Name = "stuff"
for i = 1, math.random(2, #__random)
create("StringValue", item, __random[i])
end
for _, thing in next, item:GetChildren()
__save[#save + 1] = thing.Name
end
data:SetAsync(player.Name..": stuff", __save)
end)
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
26 Jul 2014 10:41 PM
Swap PlayerAdded and PlayerRemoving around.
Report Abuse
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
26 Jul 2014 10:42 PM
This is a script I got help with about a month ago. This one works, and it;s identical to mines





Game.Players.PlayerRemoving:connect(function(Player2)
local Data2 = Game:GetService("DataStoreService"):GetDataStore(Player2.userId)
local SaveStorage = Player2.leaderstats:GetChildren()
for i = 1, #SaveStorage2 do SaveStorage[i].Value = Data2:GetAsync(SaveStorage[i].Name)
end end)
Game.Players.PlayerAdded:connect(function(Player)
local Data1 = Game:GetService("DataStoreService"):GetDataStore(Player.userId)
Player:WaitForChild("leaderstats") local LoadStorage = Player.leaderstats:GetChildren()
for i = 1, #LoadStorage do Data1:SetAsync(LoadStorage[i].Name, LoadStorage[i].Value) end
end)
Report Abuse
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
26 Jul 2014 10:45 PM
@not it didn't work.
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
26 Jul 2014 10:46 PM
Ehh... Too tired. Need to sleep.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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