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: Whats wrong with this?

Previous Thread :: Next Thread 
peoplemove12 is not online. peoplemove12
Joined: 11 Feb 2010
Total Posts: 1442
31 May 2014 05:42 PM
It has no error. It just does not load. What did i do wrong?

local DataStore = Game:GetService("DataStoreService"):GetDataStore("Stats")

Game.Players.PlayerRemoving:connect(function(Player1)
Player1:WaitForDataReady()
local key = "user_" .. Player1.userId
DataStore:UpdateAsync(key, function(oldValue)
local Data1 = Player1:WaitForChild("leaderstats"):GetChildren()
for i= 1,#Data1 do
Data1:SetAsync(Data1[i].Name, Data1[i].Value)
end
end)
Game.Players.PlayerRemoving:connect(function(Player2)
Player2:WaitForDataReady()
local key = "user_"..Player2.userId
if DataStore:GetAsync(key) ~= nil then
local Data2 = Player2:WaitForChild("leaderstats"):GetChildren()
for i = 1, #Data2 do
Data2:GetAsync(Data2[i].Name)
end
end
end)
end)
Report Abuse
SamuelKingx is not online. SamuelKingx
Joined: 27 Jan 2012
Total Posts: 3472
31 May 2014 05:43 PM
You're updating the async when they enter. You cannot update an async before you set the async.
Report Abuse
peoplemove12 is not online. peoplemove12
Joined: 11 Feb 2010
Total Posts: 1442
31 May 2014 05:45 PM
It's just that? It's all fine after i use SetAsync?
Report Abuse
peoplemove12 is not online. peoplemove12
Joined: 11 Feb 2010
Total Posts: 1442
31 May 2014 05:53 PM
It made no difference. Still does the same thing. Anyone?
Report Abuse
Usering is online. Usering
Joined: 18 Aug 2012
Total Posts: 10281
31 May 2014 06:03 PM
You have to use the Increment, Set, and Get methods on GlobalDataStore, not get GetDataStore. Change DataStore to game:GetService("DataStoreService"):GetGlobalDataStore().

if that doesn't help, try finding the error
Report Abuse
peoplemove12 is not online. peoplemove12
Joined: 11 Feb 2010
Total Posts: 1442
31 May 2014 06:11 PM
I'm actually trying to save the stats, tried that nothing. Same thing. Anyone else?
Report Abuse
Usering is online. Usering
Joined: 18 Aug 2012
Total Posts: 10281
31 May 2014 06:12 PM
Did you not read what I posted? I literally gave you the answer.

local DataStore = Game:GetService("DataStoreService"):GetDataStore("Stats")

to

local DataStore = Game:GetService("DataStoreService"):GetGlobalDataStore()
Report Abuse
peoplemove12 is not online. peoplemove12
Joined: 11 Feb 2010
Total Posts: 1442
31 May 2014 06:16 PM
I said i tried that.
Report Abuse
Usering is online. Usering
Joined: 18 Aug 2012
Total Posts: 10281
31 May 2014 06:18 PM
1. You don't need to call Player:WaitForDataReady() for DataStore. DataStore is always ready to save and retrieve, since it does not save to the player.
2. You're trying to call SetAsync on GetChildren() when you should set it on DataStore
"Data1 = Player1:WaitForChild("leaderstats"):GetChildren()"
Report Abuse
peoplemove12 is not online. peoplemove12
Joined: 11 Feb 2010
Total Posts: 1442
31 May 2014 06:28 PM
So if i set "Data1 = Player1:WaitForChild("leaderstats"):GetChildren()" to
"DataStore = Player1:WaitForChild("leaderstats"):GetChildren()"


what should Data1 equal?

for i= 1,#Data1 do
Data1:SetAsync(Data1[i].Name, Data1[i].Value)
end
end)
end)
Report Abuse
peoplemove12 is not online. peoplemove12
Joined: 11 Feb 2010
Total Posts: 1442
31 May 2014 06:45 PM
Anyone?
Report Abuse
Usering is online. Usering
Joined: 18 Aug 2012
Total Posts: 10281
31 May 2014 06:52 PM
You should always set DataStore stuff to your DataStore variable.
Report Abuse
peoplemove12 is not online. peoplemove12
Joined: 11 Feb 2010
Total Posts: 1442
31 May 2014 07:09 PM
Why does it not load. I did what you said.
Report Abuse
peoplemove12 is not online. peoplemove12
Joined: 11 Feb 2010
Total Posts: 1442
31 May 2014 07:20 PM
Anyone?
Report Abuse
peoplemove12 is not online. peoplemove12
Joined: 11 Feb 2010
Total Posts: 1442
31 May 2014 07:27 PM
Someone, please?
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