Hello, everyone
I have about 5 of these - each one controlling it’s own DataStore. There’s one for Credits, Cosmetics, Armor, Settings, and then this one - which contains the “System” datastore, which controls things like if the player is banned, their total kills, total playtime, etc.
I recently tried to fix the problem with it becoming exhausted, but my efforts seem to have failed me, especially with full servers. I don’t want to hire anyone currently to rewrite it currently as I don’t have the funds. Still though, if it’s a simple fix, put the solution in a response to this. I’m not very good with DataStores, and I think this was probably something I shouldn’t have gotten into in the first place.
Code:
local stuff={
--<<------------------------------------------------------------------------------------------------>>--
"premiumMultiplier","NumberValue", 1;
"isBanned","BoolValue", false;
"numBans","NumberValue", 0;
"numWarnings","NumberValue", 0,
"storeDiscount","NumberValue", 1,
--<<------------------------------------------------------------------------------------------------>>--
"MatchesWon","NumberValue", 0,
"HighestSpree","NumberValue", 0,
"TotalKills","NumberValue", 0,
"TotalDeaths","NumberValue", 0,
"KDR","NumberValue", 0,
"TotalHeadshots","NumberValue", 0,
"TotalMatchesWon","NumberValue", 0,
"TotalTimePlayed","NumberValue", 0,
"ChallengesCompleted","NumberValue", 0,
"TotalCreditsEarned","NumberValue", 0,
"FirstTimePlaying_TEST","BoolValue", true,
}
local DS=game:GetService"DataStoreService":GetDataStore("SYSTEM","global")
game:GetService"Players".PlayerAdded:Connect(function(p)
local leaderstats=p:WaitForChild("SYSTEM",.3)or table.foreach({''},function(i)i=Instance.new("Folder",p)i.Name="SYSTEM"return(i)end)
for x=1,#stuff,3 do
local val=Instance.new(stuff[x+1])
val.Parent=leaderstats
val.Name=stuff[x]
local save;
delay(6,function()
save=true;
end)
local data=DS:GetAsync(p.UserId..stuff[x])
val.Value=data and type(stuff[x+2])==type(data)and data or stuff[x+2]
print("Creating SystemService for "..p.Name)
val.Changed:Connect(function()
if save then
save=false;
DS:SetAsync(p.UserId..val.Name,val.Value)
delay(6,function()
save=true;
end)
end
end)
end
end)