My DataStore script isn't working it keep getting an error saying that GetAsync() is not a valid member of datastore?
local datastore = game:GetService("DataStoreService") game.Players.PlayerAdded:connect(function(player) local leaderstats = Instance.new("IntValue") leaderstats.Name = "Stat" leaderstats.Parent = player local stata = Instance.new("BoolValue") stata.Name = "NewPlayer" stata.Parent = leaderstats local key = "user-" .. player.userId local storeditems = datastore:GetAsync(key) if storeditems then stata.Value = storeditems[1] else local items = {stata.Value} datastore:SetAsync(key, items) end end) game.Players.PlayerRemoving:connect(function(player) local items = {player.Leaderstats.Stat.Value} local key = "user-" .. player.userId datastore:SetAsync(key, items) end)
I went through the entire script trying to figure out what went wrong and the problem is at the beginning of the script.
On line 1 you defined 'DataStoreService' but you didn't define the DataStore for your game. This can be done with ':GetDataStore()'
Example:
local datastore = game:GetService("DataStoreService"):GetDataStore('GameData')
If you need anymore help feel free to contact me on Roblox. Please check out these links for reference: http://wiki.roblox.com/index.php?title=API:Class/DataStoreService/GetDataStore
http://wiki.roblox.com/index.php?title=API:Class/DataStoreService