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: DataStore not Saving/Loading.

Previous Thread :: Next Thread 
DrRandomous is not online. DrRandomous
Joined: 25 Mar 2011
Total Posts: 1702
17 Mar 2014 01:53 PM
I'm not sure what whether it is loading or saving that is the issue, but it isn't working. There is no errors.
--------------------------------------------------------------------------------
local playerlist = game.Workspace:findFirstChild("PlayerList")

game.Players.PlayerAdded:connect(function(player)
local dataStore = game:GetService("DataStoreService"):GetDataStore(player.Name.."_HealingPotions")
local newPlayer = Instance.new("StringValue", playerlist) --I am going to do it like this, so that I can access the Player's number of healing potions from a LocalScript.
newPlayer.Name = player.Name
local healingPotionsValue = Instance.new("IntValue", newPlayer)
healingPotionsValue.Name = "HealingPotions"
healingPotionsValue = dataStore:GetAsync("HealingPotions")
healingPotionsValue.Changed:connect(function()
dataStore:SetAsync(healingPotionsValue.Name, healingPotionsValue.Value)
end)
end)

game.Players.PlayerRemoving:connect(function(player)
local dataStore = game:GetService("DataStoreService"):GetDataStore(player.Name.."_HealingPotions")
local plrInList = playerlist:findFirstChild(player.Name)
local hP = plrInList:findFirstChild("HealingPotions")
dataStore:SetAsync("HealingPotions", hP.Value)
end)



Thank you,

Dr.
Report Abuse
DataStore is not online. DataStore
Joined: 07 Feb 2012
Total Posts: 8540
17 Mar 2014 01:59 PM
When did I (get it?) have a '.Changed' event?

healingPotionsValue = dataStore:GetAsync("HealingPotions")
healingPotionsValue.Changed:connect(function()
Report Abuse
DrRandomous is not online. DrRandomous
Joined: 25 Mar 2011
Total Posts: 1702
17 Mar 2014 02:14 PM
I'm confused? What do you mean?
Report Abuse
DataStore is not online. DataStore
Joined: 07 Feb 2012
Total Posts: 8540
17 Mar 2014 02:16 PM
healingPotionsValue = dataStore:GetAsync("HealingPotions")
healingPotionsValue.Changed:connect(function()

Which is why I posted the above two lines.

I believe you meant,
healingPotionsValue.Value = dataStore:GetAsync("HealingPotions")
Report Abuse
DrRandomous is not online. DrRandomous
Joined: 25 Mar 2011
Total Posts: 1702
17 Mar 2014 02:19 PM
Thank you :)

It worked, gosh, I feel a little stupid now.
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