Xephyric
|
  |
| Joined: 26 Mar 2009 |
| Total Posts: 2270 |
|
|
| 09 May 2014 10:57 PM |
game.Players.PlayerAdded:connect(function(p) kills = game:GetService("DataStoreService"):GetOrderedDataStore("Kills") p:WaitForChild("leaderstats") ls = p.leaderstats ls.Kills.Value = kills:GetAsnyc(p.Name) ------------- LINE 19 print("Loaded: ".. p.Name ..", ".. kills:GetAsync(p.Name))
end)
--
22:55:16.046 - GetAsnyc is not a valid member of OrderedDataStore 22:55:16.047 - Script 'ServerScriptService.Script', Line 19 22:55:16.047 - Stack End
-- I don't understand why it won't work.
Also, is there a way to check if the value exists before trying to retrieve it? |
|
|
| Report Abuse |
|
|
Kingmouli
|
  |
| Joined: 28 Sep 2012 |
| Total Posts: 1292 |
|
|
| 09 May 2014 11:01 PM |
Read carefully line 19 I'm sure you'll facepalm... |
|
|
| Report Abuse |
|
|
Xephyric
|
  |
| Joined: 26 Mar 2009 |
| Total Posts: 2270 |
|
|
| 09 May 2014 11:02 PM |
qq ive been stuck on this for like 30 minutes i feel so dumb |
|
|
| Report Abuse |
|
|
Kingmouli
|
  |
| Joined: 28 Sep 2012 |
| Total Posts: 1292 |
|
|
| 09 May 2014 11:06 PM |
| I don't remember if DataStore returns 0 or nil if an int value doesn't exist. You could use an if statement to check it |
|
|
| Report Abuse |
|
|
|
| 09 May 2014 11:25 PM |
Heres a script i crafted for one of my games
local DataStore=game:GetService("DataStoreService"):GetGlobalDataStore() game.Players.PlayerAdded:connect(function (player) --playerstat=DataStore:GetDataStore(player.userId.."Loyalty", 0) stats=Instance.new("IntValue") stats.Name="leaderstats" stats.Parent=player loy=Instance.new("NumberValue") loy.Name="Food" loy.Parent=stats loy.Value=DataStore:GetAsync(player.userId.."Food") or 0 wood=Instance.new("NumberValue") wood.Name="Wood" wood.Parent=stats wood.Value=DataStore:GetAsync(player.userId.."Wood") or 0 stone=Instance.new("NumberValue") stone.Name="Stone" stone.Parent=stats stone.Value=DataStore:GetAsync(player.userId.."Stone") or 0 buildings=Instance.new("Model") buildings.Name="Buildings" buildings.Parent=player print('Success') end)
game.Players.PlayerRemoving:connect(function (player) DataStore:UpdateAsync(player.userId.."Food" ,function() return player.leaderstats.Food.Value end) DataStore:UpdateAsync(player.userId.."Wood" ,function() return player.leaderstats.Wood.Value end) DataStore:UpdateAsync(player.userId.."Stone" ,function() return player.leaderstats.Stone.Value end) print('Worked') end)
Saves stats when leaving and loads them when joining |
|
|
| Report Abuse |
|
|
|
| 10 May 2014 12:26 AM |
ls.Kills.Value = kills:GetAsnyc(p.Name) ------------- LINE 19 ls.Kills.Value = kills:GetAsnyc(p.Name) kills:GetAsnyc(p.Name) GetAsnyc Asnyc ny |
|
|
| Report Abuse |
|
|