|
| 28 Jul 2015 10:53 PM |
I have a universe game and I want the data to save cross server, but it isn't working here is the 2 scripts in each of the games at the moment. I really need help on this one.
Lobby: --Data Script-- --Variables-- local DS = game:GetService("DataStoreService"):GetDataStore("DataStore", "Cash") --Datastore-- game.Players.PlayerAdded:connect(function(player) player.PlayerGui:WaitForChild("Game") local key = "COR6_ "..player.userId local cash = player.PlayerGui.Game.Cash if DS:GetAsync(key) then cash.Value = DS:GetAsync(key) player.PlayerGui.Game.MainFrame.GameGUI.Cobble.Cash.Text = "Datastore Test Cash: " .. cash.Value else cash.Value = 100 DS:SetAsync(key, cash.Value) end end) game.Players.PlayerRemoving:connect(function(player) local key = "COR6_ "..player.userId local cash = player.PlayerGui.Game.Cash DS:SetAsync(key, cash.Value) end)
Gameplay: --Data Script-- --Variables-- local DS = game:GetService("DataStoreService"):GetOrderedDataStore("DataStore", "Cash") --Datastore-- game.Players.PlayerAdded:connect(function(player) player.PlayerGui:WaitForChild("Gameplay") local key = "COR6_ "..player.userId local cash = player.PlayerGui.Gameplay.MainFrame.GUIData.Cash if DS:GetAsync(key) then cash.Value = DS:GetAsync(key) player.PlayerGui.Gameplay.MainFrame.Game.Background.Loadouts.Cash.Text = "Cash: " .. cash.Value player.PlayerGui.Gameplay.MainFrame.Game.Background.Cash.Text = "Cash: " .. cash.Value player.PlayerGui.Gameplay.MainFrame.Game.Background.Extra.Cash.Text = "Cash: " .. cash.Value else cash.Value = 100 DS:SetAsync(key, cash.Value) end end) game.Players.PlayerRemoving:connect(function(player) local key = "COR6_ "..player.userId local cash = player.PlayerGui.Gameplay.MainFrame.GUIData.Cash DS:SetAsync(key, cash.Value) end)
|
|
|
| Report Abuse |
|
|
|
| 28 Jul 2015 10:59 PM |
| http://wiki.roblox.com/index.php?title=Games |
|
|
| Report Abuse |
|
|
|
| 28 Jul 2015 11:03 PM |
| The lobby is the first game and the gameplay is second they are both under the games and places configuration. |
|
|
| Report Abuse |
|
|
|
| 28 Jul 2015 11:05 PM |
All too often, it's someone forgetting this:
http://wiki.roblox.com/index.php?title=OnClose |
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 28 Jul 2015 11:30 PM |
| "The purpose of this callback is to give creators a chance to save data using HttpService or Data Store before the game shuts down." |
|
|
| Report Abuse |
|
|
|
| 28 Jul 2015 11:53 PM |
| But I Use playerremoving for that... Im so confused |
|
|
| Report Abuse |
|
|
|
| 29 Jul 2015 04:17 AM |
| If you think this will help me then convince me because I don't understand it. |
|
|
| Report Abuse |
|
|
|
| 29 Jul 2015 04:19 AM |
| Are you dumb? The game is going to get shutdown before the PlayerLeaving event finishes or is fired at all, which is why the game.OnClose callback exists. |
|
|
| Report Abuse |
|
|
|
| 29 Jul 2015 05:22 AM |
game.OnClose = function() wait(10) end
Enjoying your stay at the Scripters Forum? Join this! http://www.roblox.com/My/Groups.aspx?gid=2582784 |
|
|
| Report Abuse |
|
|
|
| 29 Jul 2015 03:22 PM |
| Ok done I figured it out but it still says 0 cash in lobby and says 100 cash in Gameplay? and its not ordered anymore... |
|
|
| Report Abuse |
|
|
|
| 29 Jul 2015 04:18 PM |
| I fixed it thanks for the help! |
|
|
| Report Abuse |
|
|