DataStore Error

hi, i was working at my custom DataStore Sistem but at save when i use SetAsync i get this error:

[19:13:25.067 - SetAsync is not a valid member of GlobalDataStore]

but it isn’t a GlobalDataStore

and when i use UpdateAsyc:

[19:22:02.437 - Unable to cast value to function]

my script to save:


function module:Save(values,key,plr,data)
	if table.find(Values,values) and plr then
		DataStoreService:GetDataStore(tostring(key)):SetAsync(plr.UserId,data)
	end
end

I think you should give it time for the GlobalDataStore to load:

local DS = game:GetService("DataStoreService"):GetDataStore(key) 
wait() -- optional wait, - it can be removed
DS:SetAsync(plr.UserId, data) 

Here’s an example on how you use UpdateAsync:

DS:UpdateAsync(key, function(oldValue) 
    -- to update the value, you need to return the new data 
    return newValue
end) 
1 Like

about UpdateAsync() now i read i need to use a function to use it

thanks, only 0.02 take to load but every 0.0001 second is inportant…