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 help.

Previous Thread :: Next Thread 
masterfire113 is not online. masterfire113
Joined: 01 Nov 2009
Total Posts: 125
18 Jul 2014 10:00 AM
I have been having issues with making a functional data store script. This script runs without errors, yet when I join the game the data has not been saved. The "mapNumb" referenced is an IntValue inside of starterpack.

game.Players.PlayerRemoving:connect(function(player)
local datastore = game:GetService("DataStoreService"):GetDataStore("MapStats")
player:WaitForDataReady()
wait(2)
mapDist = player.Backpack:FindFirstChild("mapNumb").Value
datastore:SetAsync(player.Name, mapDist)
end)

game.Players.PlayerAdded:connect(function(player)
local datastore = game:GetService("DataStoreService"):GetDataStore("MapStats")
repeat wait() until player.Character
player:waitForDataReady()
wait(2)
mapDist2 = player.Backpack:FindFirstChild("mapNumb").Value
datastore:SetAsync(player.Name, mapDist2)
player.Backpack.mapNumb.Value = datastore:GetAsync(player.Name)
end)

game.OnClose = function()
wait(3)
end
Report Abuse
masterfire113 is not online. masterfire113
Joined: 01 Nov 2009
Total Posts: 125
18 Jul 2014 10:06 AM
I've made four separate posts asking this same exact question, and I still have not received help!
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
18 Jul 2014 10:08 AM
Don't use WaitForDataReady, that's for something else.

datastore:SetAsync(player.Name, mapDist2)

You are just overriding the data, that's why.
Report Abuse
masterfire113 is not online. masterfire113
Joined: 01 Nov 2009
Total Posts: 125
18 Jul 2014 10:08 AM
Does anyone even know how to correctly use Data Store? This is ridiculous.
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
18 Jul 2014 10:10 AM
...Eh?
Report Abuse
masterfire113 is not online. masterfire113
Joined: 01 Nov 2009
Total Posts: 125
18 Jul 2014 10:10 AM
I am overriding the data with the updated number, or at the very least I SHOULD be.

I join my game and the value of mapNumb is 1.

I change the value of mapNumb to 2, verify that it is actually 2, then leave the game

I join the game and the value of mapNumb is 1 again.
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
18 Jul 2014 10:13 AM
You're not setting MapNumb...
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
18 Jul 2014 10:15 AM

datastore:SetAsync(player.Name, mapDist2)
player.Backpack.mapNumb.Value = datastore:GetAsync(player.Name)


*New IntValue has value 0
*Sets DataStore to 0
*Loads 0 into the IntValue
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
18 Jul 2014 10:16 AM
Also, every time they reset they will lose all their stats.
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
18 Jul 2014 10:16 AM
Oops sorry. Nevermind
Report Abuse
masterfire113 is not online. masterfire113
Joined: 01 Nov 2009
Total Posts: 125
18 Jul 2014 10:20 AM
What do you suggest I do to fix it, then?
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