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: GetAsync

Previous Thread :: Next Thread 
Xephyric is not online. 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 is not online. 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 is not online. 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 is not online. 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
HILLBILLYY is online. HILLBILLYY
Joined: 08 May 2010
Total Posts: 764
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
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
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
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