Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i fix this? it says SetAsync() and GetAsync() isnt a part of data store service

Asked by 2 years ago

local DStoreService = game:GetService("DataStoreService") local CashStore = DStoreService:GetDataStore("Cash")

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

local CashValue = plr:WaitForChild("leaderstats"):WaitForChild("Cash").Value
DStoreService:UpdateAsync("plr_"..plr.UserId, CashValue)

end)

game.Players.PlayerRemoving:Connect(function(plr) DStoreService:GetAsync("plr_"..plr.UserId) end)

1 answer

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

You're supposed to call it from the CashStore instead of the ACTUAL service itself which holds no data at all

local DStoreService = game:GetService("DataStoreService") 
local CashStore = DStoreService:GetDataStore("Cash")

game.Players.PlayerAdded:Connect(function(plr)
    local CashValue = plr:WaitForChild("leaderstats"):WaitForChild("Cash").Value
    CashStore:UpdateAsync("plr_"..plr.UserId, CashValue)
end)

game.Players.PlayerRemoving:Connect(function(plr) 
    CashStore:GetAsync("plr_"..plr.UserId) 
end)

Upvote if it helps! I'll appreciate it

0
also UpdateAsync takes a function, while SetAsync just takes the value to put in the Datastore like they did here OfficerBrah 494 — 2y
Ad

Answer this question