That is because you’re not even looking at the documentation it has.
Here’s the link for it: ProfileService
And yes it does actually have SetAsync, so you’re wrong once again.
That is because you’re not even looking at the documentation it has.
Here’s the link for it: ProfileService
And yes it does actually have SetAsync, so you’re wrong once again.
also im getting this warning when i test the server by myself… so weird
DataStore request was added to queue. If request queue fills, further requests will be dropped. Try sending fewer requests.Key = 464517206
Add a cooldown, there is no way you need to write that many requests within those 6 seconds for one single key.
You can also add a queue system.
the documentations are too bright, there isn’t dark mode at the documentations.
do you have any proof?
there is a cooldown tho
onlychar
If you actually read, you can find the proof very easily.
i can’t because I can’t see things at light mode
if you are sending too many request on a Short period of time, it will give you this warning
Sending way too many will result in an error, which is why you wrap it in a pcall()
I prefer to not use modules like DataStore2
or ProfileService
, not because they’re bad, but because i’d rather make my own rather than use someone elses code
Which i feel like is a valid reason
Then you are probably using the same datastore name in another script.
They are not bad at all.
DataStore v2 is bad, not ProfileService.
It’s cause you are trying to save new data to the same key you used less than 6 seconds ago.
I would recommend only saving data when the player leaves the game. Doing a periodic save can still cause the datastore to queue, especially if you pair it with saving data when a player leaves. For example, if a player leaves the game right after their data was just saved through say a while loop, the game will try to save their data again and it will get added to the queue.
Also, to the people saying ProfileService is useless or “bad”, you clearly haven’t used ProfileService, or haven’t used it how it’s supposed to be used. In my opinion ProfileService is by far the best way to save and manage data for your game no matter how big or small it is. It offers many great features that most data programmers on Roblox fail to account for, one of the most notable being session locking. I would HIGHLY recommend doing more research on it before claiming it’s “useless”.
Please re read my post.
Yes, and I agree, I’ll also add that I personally wouldn’t waste hour after hour making the perfect system when there are other options available
once again, the key is ONLY being saved once.
Ill send a snippet of the code:
local function PlayerRemoving(plr)
local currentTime = tick()
if currentTime - lastSave > 6 then -- Only save the data if more than 6 seconds has passed since the last save
SaveData(plr)
print("saved")
lastSave = currentTime
end
end
How about you show us the entire script instead of us guessing what could be wrong?
Can you show all of your code instead of just a little bit? That code doesn’t help at all.
sure, it’s SimpleAdmin.
NOT my code, code found in https://create.roblox.com/marketplace/asset/5300444087/SimpleAdmin-Source (with edits)
Service, Config = nil, nil
--[[
SimpleAdmin | Data
--]]
-- Variables
local Environment = require(script.Parent:WaitForChild("Environment"))
local DataStoreService = game:GetService("DataStoreService")
local lastSave = tick()
-- Module
local Data = {
DefaultPlayerData = {}; -- This is data that'll be assigned to the player when they join.
DefaultGlobalData = { -- This is data that is saved live and needs to be shared across all game servers.
Permissions = {};
Bans = {};
};
Cache = {}; -- We don't want to hit API limits; this will keep player data while they're in-game and it'll be saved when they leave.
GlobalDataStore = nil; -- These are set when the script is initialized because we need to access the SimpleAdmin environment to get the key.
PlayerDataStore = nil; -- ^
}
Data.Init = function()
Environment.Apply()
Data.GlobalDataStore = DataStoreService:GetDataStore(Config.DataStoreKey .. "_GLOBAL");
Data.PlayerDataStore = DataStoreService:GetDataStore(Config.DataStoreKey .. "_PLAYERS");
for i = 1, 3 do
local Success, Return = pcall(function()
for k,v in pairs(Data.DefaultGlobalData) do
print("getting global data")
local GlobalData = Data.GlobalDataStore:GetAsync(k)
if not GlobalData then
print("setting global data")
Data.GlobalDataStore:SetAsync(k, v)
end
end
end)
if Success then
break
else
warn("SimpleAdmin | Data Init Error | " .. Return)
end
end
local function PlayerAdded(plr)
local PlayerData = Data.GetPlayerData(plr) or Service.CopyTable(Data.DefaultPlayerData)
if PlayerData then
Data.Cache[plr] = PlayerData
end
end
local function SaveData(plr)
local PlayerData = Data.Cache[plr]
if PlayerData then
print("saving plr data")
wait();
Data.PlayerDataStore:SetAsync(plr.UserId, PlayerData)
end
end
local function PlayerRemoving(plr)
local currentTime = tick()
if currentTime - lastSave > 6 then -- Only save the data if more than 1 second has passed since the last save
SaveData(plr)
print("saved")
lastSave = currentTime
end
end
for _,v in pairs(Service.Players:GetPlayers()) do
PlayerAdded(v)
end
game:BindToClose(function()
for _,v in pairs(Service.GetPlayers()) do
SaveData(v)
wait(6)
end
end)
Service.Players.PlayerAdded:Connect(PlayerAdded)
Service.Players.PlayerRemoving:Connect(PlayerRemoving)
end
Data.GetGlobal = function(self, key)
for i = 1, 3 do
local Ret
local Success, Return = pcall(function()
print("getting return global data")
local GlobalData = Data.GlobalDataStore:GetAsync(key)
if GlobalData then
Ret = GlobalData
end
end)
if Success then
return Ret
else
warn("SimpleAdmin | GetGlobal Error | " .. Return)
end
end
end
Data.SetGlobal = function(self, key, val)
for i = 1, 3 do
local Success, Return = pcall(function()
print("getting globaldata")
Data.GlobalDataStore:SetAsync(key, val)
end)
if Success then
break
else
warn("SimpleAdmin | SetGlobal Error | " .. Return)
end
end
end
Data.GetPlayerData = function(plr)
for i = 1, 3 do
local Success, Data = pcall(function()
print("getting plrdata")
return Data.PlayerDataStore:GetAsync(plr.UserId)
end)
if Success then
return Data
end
wait(.5)
end
end
return Data
i added the wait(6) and >6
it use to be no wait(6) and >1
You’re getting the data 3 times for no reason at all, you aren’t even handling the pcall right.
You’re also setting it 3 times, very bad practice.