|
| 01 May 2014 03:34 PM |
local DataStore=game:GetService("DataStoreService")
script.Parent.Touched:connect(function (hit) player=game.Players:playerFromCharacter(hit.Parent) if player~=nil and player:FindFirstChild("leaderstats")~=nil then
DataStore:UpdateAsync(player.userId.."Loyalty" , player.leaderstats.LoyaltyPoints.Value) ----Gettting problems with UpdateAsync not bring a valid member of datastoreservice
print('Saved') end end)
|
|
|
| Report Abuse |
|
|
|
| 01 May 2014 03:38 PM |
local DataStore=game:GetService("DataStoreService"):GetGlobalDataStore()
script.Parent.Touched:connect(function(hit) player=game.Players:GetPlayerFromCharacter(hit.Parent) if player and player:FindFirstChild("leaderstats")then
DataStore:UpdateAsync(player.userId.."Loyalty" ,function()return player.leaderstats.LoyaltyPoints.Value end) print('Saved') end end) |
|
|
| Report Abuse |
|
|
maxomega3
|
  |
| Joined: 11 Jun 2010 |
| Total Posts: 10668 |
|
|
| 01 May 2014 03:38 PM |
| Either make DataStore a global variable, or define it right before you index it. It's probably run out of Scope by now. |
|
|
| Report Abuse |
|
|
|
| 01 May 2014 03:39 PM |
also read this
about those 3 methods
:GetGlobalDataStore() :GetOrderedDataStore() :GetDataStore("yourstorenamehere")
http://wiki.roblox.com/index.php?title=RBX.lua.DataStoreService_(Object) |
|
|
| Report Abuse |
|
|
|
| 01 May 2014 03:41 PM |
@max
when using UpdateAsync he have to put a function that returns a value he can also get old value like this
DataStore:UpdateAsync(player.userId.."Loyalty", function(oldValue) local newValue = oldValue+1--this is used to count visits per player :) return newValue end ) |
|
|
| Report Abuse |
|
|
|
| 01 May 2014 03:42 PM |
You don't understand UpdateAsync...
DataStore:UpdateAsync(player.userId .. "Loyalty", function() new = player.leaderstats.LoyaltyPoints.Value end) |
|
|
| Report Abuse |
|
|
maxomega3
|
  |
| Joined: 11 Jun 2010 |
| Total Posts: 10668 |
|
|
| 01 May 2014 03:42 PM |
| Well I have no idea. I'm still a dinosaur using Data_P. |
|
|
| Report Abuse |
|
|
|
| 01 May 2014 03:43 PM |
Right above end) say return new
Sorry. |
|
|
| Report Abuse |
|
|
|
| 01 May 2014 03:45 PM |
| but you dont need to create a variable and then return that variable you could just return a number |
|
|
| Report Abuse |
|
|