Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why doesn't my datastore work (GetASync is not a valid member of GlobalDataStore)?

The datastore isn't working it's giving me an error: GetASync is not a valid member of GlobalDataStore "DataStoreService.NadaSplitBaseball"

here is the code:

local DataStore = game:GetService("DataStoreService")

local myDataStore = DataStore:GetDataStore("NadaSplitBaseball")

game.Players.PlayerAdded:Connect(function(plr) local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = plr

local Strength = Instance.new("NumberValue")
Strength.Name = "Strength"
Strength.Parent = leaderstats
Strength.Value = 0

local data
local success, errormessage = pcall(function()
	data = myDataStore:GetASync(plr.UserId.."-Strength")
end)

if success then
	Strength.Value = data
else
	print("There was an error while giving Player Data.")
	warn(errormessage)
end

end)

game.Players.PlayerRemoving:Connect(function(plr)

local success, errormessage = pcall(function()

	myDataStore:SetASync(plr.UserId.."-Strength", plr.leaderstats.Strength.Value)
end)


if success then
	print("Player Data successfully saved!")
else
	print("There was an error while saving Player Data.")
	warn(errormessage)
end

end) end)

1 answer

✓ Accepted answer

This is a simple spelling mistake. It should be Async rather than ASync. This applies for both the Get and Set functions.

data = myDataStore:GetAync(plr.UserId.."-Strength")

myDataStore:SetAsync(plr.UserId.."-Strength",

Also make sure that there is data before setting their leaderstats equal to their data!

if success and data then
	Strength.Value = data
else
	print("There was an error while giving Player Data.")
	warn(errormessage)
end

This discussion is preserved as it was. New answers, comments, and votes are closed.