Feedback on my datastore module

Is this an efficient way to save data through a module?.

local module = {}


local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("Stars")


module.GetData = function(Player)
	
		
local Data = DataStore:GetAsync(Player.UserId)
	
return Data	
		
	
end


module.SaveData = function(Player,Val)

	DataStore:SetAsync(Player.UserId,Val.Value)
	print("done")
end


return module

At this point, why are you even making it a module? Your module doesn’t do anything except wrap DataStore functions and it provides no additional utility either. You might as well just call DataStore methods directly (and pcall them too - you should always use pcall with DataStore calls).

It’d be better if your module actually had some kind of tooling that would warrant it being contained in a module and that would also provide more substance for the sake of the Code Review category.

Code Review is for threads where you know of points you don’t like and you request for feedback or improvements on them. Your job is to find out if it’s efficient or not, not ours. We provide feedback based on your research/analysis/testing/whatever on what you’ve specifically highlighted as potentially problematic and what you’d like improvements on.

4 Likes

I would recommend using something like ProfileService It takes care of a lot of edge cases for you.

It offers no benifits over doing it in the script you are writing.

Theres no pcall() use and no useful functions.

It could do with a lot of work.

1 Like