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

Data Store API doesn't see if player has data because getasync isnt available?

Asked by
LuaDLL 253 Moderation Voter
5 years ago
function api.check(player)
    local Player_Key = (DataStoreKey.."_"..player.userId)
    local Player_Data = Datastore:GetAsync(Player_Key)
    if Player_Data then
        return true
    else
        return false
    end
end

Error: GetAsync is not a valid member of DatastoreService

0
Change DatastoreService to DataStoreService Leamir 3138 — 5y
0
I have it like this local Datastore = game:GetService("DataStoreService") LuaDLL 253 — 5y
0
Did you use the GetDataStore() Method? Like this: local DataStore = game:GetService("DataStoreService"):GetDataStore('DataStoreNameHere") zblox164 531 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago

This is because you are trying to use :GetAsync() on DataStoreService. The method does not exist for that. However, if you did :GetAsync() on a datastore, it would.

Here is what I mean:

local dss= game:GetService("DataStoreService") -- Get the service
local datastore = dss:GetDataStore("TestDataStore") -- Get the datastore

dss:GetAsync(key) -- Won't work because GetAsync() is not a method of DataStoreService.
datastore:GetAsync(key) -- Will work because GetAsync() is a method of DataStore

Here is a link if you want to learn more about saving data.

0
Oh yea forgot about GetDataStore Lol but thanks! LuaDLL 253 — 5y
0
Np Operation_Meme 890 — 5y
Ad

Answer this question