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, Having issues

Previous Thread :: Next Thread 
HILLBILLYY is online. HILLBILLYY
Joined: 08 May 2010
Total Posts: 764
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
brinkokevin is not online. brinkokevin
Joined: 25 Jul 2012
Total Posts: 1673
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 is not online. 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
brinkokevin is not online. brinkokevin
Joined: 25 Jul 2012
Total Posts: 1673
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
brinkokevin is not online. brinkokevin
Joined: 25 Jul 2012
Total Posts: 1673
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
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
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 is not online. 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
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
01 May 2014 03:43 PM
Right above end) say return new


Sorry.
Report Abuse
brinkokevin is not online. brinkokevin
Joined: 25 Jul 2012
Total Posts: 1673
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
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