Hello! I am creating a currency system used in my Club Game, Club Void, and I was wondering as to why I am getting the failure to fetch print on my output? The error it brings is "GetASync is NOT a valid member of Global Data"
Here is an image of the failed output: https://gyazo.com/d23d2e045cc79e143a626e9c4f4d6033 Here is my code:
local dss = game:GetService("DataStoreService")
local mydatastore = dss:GetDataStore("mydatastore")
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
local vcash = Instance.new("IntValue")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
vcash.Name = "VCash"
vcash.Parent = leaderstats
local data
local success, errormessage = pcall(function()
data = mydatastore:GetASync(player.UserId.."-VCash")
end)
if success then
vcash.Value = data
else
print("Error Fetching Data!")
warn(errormessage)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local success, errormessage = pcall(function()
mydatastore:SetASync(player.UserId.."-VCash",player.leaderstats.vcash.Value)
end)
if success then
print("Stats Saved!")
else
print ("Saving Failed!")
warn(errormessage)
end
end)

1 comment
Okay I edited script for you, it should work.