I had a DataStore module named “DataPersistence” that replaced the deprecated roblox system of the same name. I slightly refactored the code to add typechecking and it got deleted for “Misusing Roblox Systems”
This is the model being uploaded
DataPersistence.rbxm (3.2 KB)
This is the former URL of the module:
This is the code of the update that got it deleted
DataPersistenceLoader:
local dat = require(game.ServerScriptService.DataPersistence)
local frequency = 5
game.Players.PlayerAdded:Connect(function(p)
dat:LoadPlayer(p)
p = nil
end)
game.Players.PlayerRemoving:Connect(function(p)
if p.Character then
p.Character:Destroy()
p.Character = nil
end
dat:RemovePlayer(p)
p = nil
end)
game:BindToClose(function()
for i,v in pairs(game.Players:GetPlayers()) do
if dat:IsReady(v) then
if v.Character then
v.Character:Destroy()
v.Character = nil
end
dat:RemovePlayer(v)
v = nil
end
end
end)
while true do
task.wait(frequency*60)
for i,v in pairs(game.Players:GetPlayers()) do
task.spawn(dat.SavePlayer,dat,v)
end
end
DataPersistence:
--!optimize 2
--!strict
--DataPersistence by AdvancedOpenGL
local dss = game:GetService("DataStoreService")
local saveStore = dss:GetDataStore("PlayerSaveData")
local cached = {}
local locked = {}
local joinFunctions = {}
local module = {}
local retries = 5
type PlayerData = {
LoadNumber : (PlayerData, string) -> (number),
SaveNumber : (PlayerData, string, number) -> (),
LoadBoolean : (PlayerData, string) -> (boolean),
SaveBoolean : (PlayerData, string, boolean) -> (),
LoadString : (PlayerData, string) -> (string),
SaveString : (PlayerData, string, string) -> (),
LoadValue : (PlayerData, string) -> (any),
SaveValue : (PlayerData, string, any) -> (),
LoadInstance : (PlayerData, string) -> (),
SaveInstance : (PlayerData, string, Instance) -> (),
}
--local functions
local function loadValue(p : Player,key)
return cached[p.UserId][key]
end
local function saveValue(p : Player,key, value)
cached[p.UserId][key] = value
end
local function throwException(self,...)
error("Legacy function not supported.",2)
end
local function getFunctions(p : Player) : PlayerData
local function baseLoadFunction(self: PlayerData,key: string) : any
return loadValue(p,key)
end
local function baseSaveFunction(self: PlayerData,key: string,value : any) : any
return saveValue(p,key,value)
end
local interface : PlayerData = {
LoadNumber = baseLoadFunction,
SaveNumber = baseSaveFunction,
LoadBoolean = baseLoadFunction,
SaveBoolean = baseSaveFunction,
LoadString = baseLoadFunction,
SaveString = baseSaveFunction,
LoadValue = baseLoadFunction,
SaveValue = baseSaveFunction,
LoadInstance = throwException,
SaveInstance = throwException
}
return interface
end
local function getAsync(p : Player)
return saveStore:GetAsync(p.UserId)
end
local function setAsync(p : Player)
return saveStore:SetAsync(p.UserId,cached[p.UserId])
end
--module stuff
function module:IsReady(p : Player) : boolean
if cached[p.UserId] ~= nil and not locked[p.UserId] then
return true
else
return false
end
end
module.IsLoaded = module.IsReady --keep compatibility with old version
function module:RegisterJoinFunction(name,func)
if type(name) ~= "string" or type(func) ~= "function" then
error("Missing one or more parameter.")
else
joinFunctions[name] = func
end
end
function module:RemoveJoinFunction(name)
if type(name) ~= "string" then
joinFunctions[name] = nil
end
end
function module:GetFunctions(p:Player) : PlayerData
return getFunctions(p)
end
function module:LoadPlayer(p : Player)
local success, load = pcall(getAsync,p)
if not success then
local i = 0
while not success and i <= retries do
success, load = pcall(getAsync,p)
i += 1
end
end
if success then
locked[p.UserId] = true
cached[p.UserId] = load
if load == nil then
print("New user!")
cached[p.UserId] = {}
end
for i,v in pairs(joinFunctions) do
if type(v) == "function" then
v(p,getFunctions(p))
end
end
locked[p.UserId] = false
else
warn(load)
p:Kick("Data store failure! Error: "..load)
end
end
function module:SavePlayer(p : Player)
if not locked[p.UserId] then
locked[p.UserId] = true
local success, load = pcall(setAsync,p)
if not success then
local i = 0
while not success and i <= retries do
success, load = pcall(getAsync,p)
i += 1
end
end
if not success then
warn(load)
else
print(p.Name.."'s data saved successfully!")
end
locked[p.UserId] = false
end
end
function module:RemovePlayer(p : Player)
if cached[p.UserId] ~= nil then
if not locked[p.UserId] then
module:SavePlayer(p)
end
cached[p.UserId] = nil
locked[p.UserId] = nil
end
end
return module
it does NOT violate the rules it keeps linking to me and even doing stuff like slightly changing names and adding/removing a character results in the same thing. All appeals end within around a minute or 2 with a deny. I’ve tried 10+ times and it comes to the same result
Expected behavior
I should be able to update my module without it getting deleted. It would update just fine and nothing would happen.
A private message is associated with this bug report