|
| 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 |
|
|
| |
|
|
| 26 Jul 2014 10:29 PM |
| "only output are the prints" |
|
|
| Report Abuse |
|
|
|
| 26 Jul 2014 10:30 PM |
| Loading at disconnect and saving on connect. |
|
|
| Report Abuse |
|
|
|
| 26 Jul 2014 10:31 PM |
Also, you are using DataStores wrong.
Put everything into a table then save the table. |
|
|
| Report Abuse |
|
|
|
| 26 Jul 2014 10:31 PM |
| so is that my error, or is that what I'm supposed to do? |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 26 Jul 2014 10:32 PM |
| Load on connect and save on disconnect. |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
| |
|
|
| 26 Jul 2014 10:37 PM |
| Already told you what to do. Save on disconnect and load on connect. |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 26 Jul 2014 10:41 PM |
| Swap PlayerAdded and PlayerRemoving around. |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
| |
|
|
| 26 Jul 2014 10:46 PM |
| Ehh... Too tired. Need to sleep. |
|
|
| Report Abuse |
|
|