DataStoreCache Update - Safer Data Saving!

Hello programmers! I have finally fixed some vulnerabilities in the DataStoreCache module as well as added more functionality. Here’s a quick changelog:

  • Used pcall for safer Datastore requests.
  • Added support for multiple scripts to use the same cache.
  • You can now construct DataStoreCache in multiple sides of the script and it will return the same Cache instance.

Quick example on how to use it across Scripts:

-- Script 1
local dataStoreCache = require(script.Parent)
local cache ="KEY", "OPTIONAL SCOPE")
-- Script 2
local dataStoreCache = require(script.Parent)
local cache ="KEY", "OPTIONAL SCOPE")

It returns the same cache in both scripts.

You can grab a copy of the module here:

Gold Currency Example

[This example can be found in the Examples folder inside of the ModuleScript!

local players = game:GetService("Players")

local dataStoreCache = require(script.Parent.Parent)

	-- Get the player's datastore.
	local ds =
	-- Create a leaderstat.
	local leaderstats ="Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = plr
	local gold ="NumberValue")
	gold.Name = "Gold"
	gold.Parent = leaderstats
	local save = ds:get("gold")
	if(save ~= nil) then
		-- Player has a save.
		gold.Value = save
		-- Starting allowance?
		gold.Value = 10

	-- Get the player's datastore.
	local ds =
	local gold = plr:WaitForChild("leaderstats"):WaitForChild("Gold")
	ds:set("gold", gold.Value)

Thanks for reading my post and maybe checking out my module!
Please contact me if you have any constructive criticism/bug reports. It helps me work out the kinks in my code. :blue_heart:


1 Like

This topic was automatically closed after 1 minute. New replies are no longer allowed.