|
| 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
|
  |
| 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 |
|
|
|
| 17 Mar 2014 02:14 PM |
| I'm confused? What do you mean? |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 17 Mar 2014 02:19 PM |
Thank you :)
It worked, gosh, I feel a little stupid now. |
|
|
| Report Abuse |
|
|