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

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

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

3 comments

0

Change DatastoreService to DataStoreService

0

I have it like this local Datastore = game:GetService("DataStoreService")

0

Did you use the GetDataStore() Method? Like this: local DataStore = game:GetService("DataStoreService"):GetDataStore('DataStoreNameHere")

1 answer

✓ Accepted answer

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.

2 comments

0

Oh yea forgot about GetDataStore Lol but thanks!

0

Np

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