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: Datastore Cross Universe Problem.

Previous Thread :: Next Thread 
xXRevengeCreeperXx is not online. xXRevengeCreeperXx
Joined: 22 Nov 2012
Total Posts: 699
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
GeoVolcano is not online. GeoVolcano
Joined: 05 Jul 2012
Total Posts: 1433
28 Jul 2015 10:59 PM
http://wiki.roblox.com/index.php?title=Games
Report Abuse
xXRevengeCreeperXx is not online. xXRevengeCreeperXx
Joined: 22 Nov 2012
Total Posts: 699
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
MakerModelLua is not online. MakerModelLua
Joined: 24 Feb 2013
Total Posts: 3544
28 Jul 2015 11:05 PM
All too often, it's someone forgetting this:

http://wiki.roblox.com/index.php?title=OnClose
Report Abuse
xXRevengeCreeperXx is not online. xXRevengeCreeperXx
Joined: 22 Nov 2012
Total Posts: 699
28 Jul 2015 11:09 PM
?
Report Abuse
xXRevengeCreeperXx is not online. xXRevengeCreeperXx
Joined: 22 Nov 2012
Total Posts: 699
28 Jul 2015 11:26 PM
Why do I need OnClose?
Report Abuse
MakerModelLua is not online. MakerModelLua
Joined: 24 Feb 2013
Total Posts: 3544
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
xXRevengeCreeperXx is not online. xXRevengeCreeperXx
Joined: 22 Nov 2012
Total Posts: 699
28 Jul 2015 11:53 PM
But I Use playerremoving for that... Im so confused
Report Abuse
xXRevengeCreeperXx is not online. xXRevengeCreeperXx
Joined: 22 Nov 2012
Total Posts: 699
29 Jul 2015 04:17 AM
If you think this will help me then convince me because I don't understand it.
Report Abuse
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
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
powerhotmail123 is not online. powerhotmail123
Joined: 11 Apr 2011
Total Posts: 5041
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
xXRevengeCreeperXx is not online. xXRevengeCreeperXx
Joined: 22 Nov 2012
Total Posts: 699
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
xXRevengeCreeperXx is not online. xXRevengeCreeperXx
Joined: 22 Nov 2012
Total Posts: 699
29 Jul 2015 04:18 PM
I fixed it thanks for the help!
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