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

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

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

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

1 comment

0

also UpdateAsync takes a function, while SetAsync just takes the value to put in the Datastore like they did here

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