Hello i keep getting this error " GetAsync is not a valid member of DataStoreService." I am very new to data stores and i dont know what im doing wrong. Can someone help me?
script:
local DataStore = game:GetService("DataStoreService")
local Level1 = DataStore:GetDataStore("Level001")
local Exp1 = DataStore:GetDataStore("Exp001")
local MaxHealth1 = DataStore:GetDataStore("DefenseP001")
local Strength1 = DataStore:GetDataStore("Strength001")
local Stamina1 = DataStore:GetDataStore("Stamina001")
local Spins1 = DataStore:GetDataStore("Spins001")
local Yen1 = DataStore:GetDataStore("Yen001")
local Points1 = DataStore:GetDataStore("Points001")
local ExpNeed1 = DataStore:GetDataStore("ExpNeed001")
local Quirk1 = DataStore:GetDataStore("Quirk001")
local Fame1 = DataStore:GetDataStore("Fame001")
game.Players.PlayerAdded:Connect(function(Plr)
local stats = Instance.new("Folder", Plr)
stats.Name = "Stats"
--- Level System
local Level = Instance.new("NumberValue", stats)
Level.Name = "Level"
Level.Value = 1
local Exp = Instance.new("NumberValue", stats)
Exp.Name = "Exp"
Exp.Value = 0
local ExpNeed = Instance.new("IntValue", stats)
ExpNeed.Name = "ExpNeed"
ExpNeed.Value = 100
--- Money and Spin System
local Yen = Instance.new("IntValue", stats)
Yen.Name = "Yen"
Yen.Value = 0
local Spins = Instance.new("NumberValue", stats)
Spins.Name = "Spins"
Spins.Value = 5
--- Stats System
local Points = Instance.new("NumberValue", stats)
Points.Name = "Points"
Points.Value = 3
local MaxHealth = Instance.new("IntValue", stats)
MaxHealth.Name = "MaxHealth"
MaxHealth.Value = 100
local Stamina = Instance.new("IntValue", stats)
Stamina.Name = "Stamina"
Stamina.Value = 0
local Quirk = Instance.new("StringValue", game.StarterGui.Values)
Quirk.Name = "Abillity"
Quirk.Value = "Quirkless"
--- Fame
local leaderstats = Instance.new("Folder",Plr)
leaderstats.Name = "leaderstats"
leaderstats.Parent = Plr
local Fame = Instance.new("IntValue")
Fame.Name = "Fame"
Fame.Value = 0
Fame.Parent = leaderstats
spawn(function()
wait(4)
local StaminaBarMax = Instance.new("IntValue",stats)
StaminaBarMax.Name = "AbilityStaminaMax"
StaminaBarMax.Value = 100 + (Plr.Stats.Stamina.Value*5)
local StaminaBar = Instance.new("IntValue",stats)
StaminaBar.Name = "AbilityStamina"
StaminaBar.Value = StaminaBarMax.Value
end)
local Strength = Instance.new("IntValue", stats)
Strength.Name = "Strength"
Strength.Value = 0
local playerdata = {
Fame = Fame.Value,
Quirk = Quirk.Value,
Stamina = Stamina.Value,
MaxHealth = MaxHealth.Value,
Points = Points.Value,
Spins = Spins.Value,
Yen = Yen.Value,
ExpNeed = ExpNeed.Value,
Exp = Exp.Value,
Level = Level.Value
}
local Data = DataStore:GetAsync(playerdata)
local data = DataStore:GetAsync(Plr.UserId)
while true do
wait(30)
for _, player in pairs(game.Players:GetPlayers())do
DataStore:SetAsync(player.UserId, playerdata)
print("Saved")
end
end
end)
Times like these the dev API reference is really usefull. Here is an example script I found for using GetAsync within this article:
local DataStoreService = game:GetService("DataStoreService")
local experienceStore = DataStoreService:GetDataStore("PlayerExperience")
local success, currentExperience = pcall(function()
return experienceStore:GetAsync("Player_1234")
end)
if success then
print("Current Experience:", currentExperience)
end
now lets compare this with yours:
yeah basically its the same as what @ND_B7 said, but I recommend comparing your code with the dev api reference first.
Did you accidentally put the PlayerRemoving inside of the PlayerAdded event? Make sure they’re separate and one isn’t inside the other. Also make sure Studio Access to API Services is enabled. Data Stores can also be pretty buggy in Studio, so try publishing and testing in an actual server.