I have made a datastore script that checks if a key exists. if it does then it updates the datastore, if it doesnt find a key then it sets the datastore key but for some reason it is not finding the key at all. Here is the module script code
local module = {} local datastoreservice = game:GetService("DataStoreService") local inv = datastoreservice:GetDataStore('inventory') function module.SetInventory(pid) local val = inv:GetAsync(pid) print(val) if not val == nil then print("The datastore was found") table.insert(val,"A new datastore key!") inv:UpdateAsync(pid,val) else print("NO key was found") inv:SetAsync(pid,{" the first key"}) end end return module
here is the server side script
local invdata = require(game.ServerScriptService.datastoreinventory) local datastoreservice = game:GetService("DataStoreService") local inv = datastoreservice:GetDataStore('inventory') invdata.SetInventory('babo') wait(3) local val = inv:GetAsync('babo') print(val)