If that’s all it is, your code there looks right to me. Are you on the latest version, from GitHub?
I fixed it using GetAsync(), is it because bindable events run async?
Is there a way to check my version?
If you got your version from the free model, it is outdated. Otherwise, you are probably on the latest version.
Hello!
Before I get to the problem, I would like to share with you how I store tables using datastore2.(@Asinphi told me how to do this) In short, I make all datastores single datastores, so that way I have direct access to them.
---
I First make a table of all my datastores names:
local trailKeys = {
"Red";
"White";
"Yellow";
--ect...
}
I then use unpack
in Combine
:
dataStore2.Combine("UserData", unpack(trailKeys))
After PlayerAdded
has been fired, I then make this for loop:
for _, key in pairs(trailKeys) do
local trailDataStore = dataStore2(key, player)
trailDataStore:OnUpdate(function(newValue)
--ect...
end)
end
I can then access them very nicely in other scripts:
local redTrail = dataStore2("Red", player)
redTrail:Get(0)
-- ect...
Now I am saving about 200 single datastores(I have a lot of data). Now is this the reason why I keep getting this warning?
If it is, should I not use this method? If you can’t read it it says “Datastore request was queued”
Some more information for you to know is that I’m using the latest version of DS2, and I used the search button on this and nothing came up. There are also so errors, and the datastores still save, but it takes about 2 minutes for all the data to load in.
Have a good day!
Take a look at the warnings closely–you have the keys “Rookie”, “Advanced”, and “Best” that aren’t being combined. Try to find where these are from.
datastore2.Combine("UserData", unpack(achievementKeys), unpack(trailsTable), unpack(titlesTable))
I forgot to add unpack(titleTable)
in the combine function. But now its showing this warning on trail data.
These are all trail data
Does this mean that unpack
doesn’t work? Or am I just storing to much data?
I know this topic is old, but can it handle bulk requests? My current script sends a request every time a gun’s ammo changes
Probably not a good idea to send a request whenever you shoot a bullet, what exactly are you trying to save? And why?
Here’s a link about datastore limits.
Just gun ammo and reserve ammo.
I just checked, Datastore2 only calls :SetAsync()
when the player leaves, so it’s fine.
Multiple unpacks in a row is problematic, this is a quirk of Lua. If you called Combine multiple times, once for each unpack, it’ll work fine.
Yes–I do believe this is stated in the documentation.
I looked up many tutorials on this, I carefully looked at a lot of examples and nothing seems to be wrong with how I scripted this but some players like some 30%, especially new ones, lose their data to their previous state and I can’t seem to find the source. My game does have a global leaderboard that takes the information from datastore2, converts it to a normal ordered datastore before being recorded to the global leaderboard. I never experienced this issue for me, personally but others do.
local DataStore2 = require(1936396537)
--local DataStore2 = require(game.ServerScriptService:WaitForChild("MainModule"))
local defaultValue = 0
local defaultValue2 = -0.495
local Main = "MainStats"
DataStore2.Combine(Main,"DistanceTravelled","OrbitsCompleted")
local PlayerService = game:GetService("Players")
PlayerService.PlayerAdded:Connect(function(plr)
local DistTravelled = DataStore2("DistanceTravelled",plr) -- Distance Travelled
local OrbitsComp = DataStore2("OrbitsCompleted", plr) -- Orbits Completed
local folder = Instance.new("Folder",plr)
folder.Name = "leaderstats"
local DistTravelled2 = Instance.new("IntValue",folder)
local OrbitsComp2 = Instance.new("IntValue",folder)
DistTravelled2.Name = "Distance Travelled"
OrbitsComp2.Name = "Orbits Completed"
-- Load
local function Update(UpdatedValue)
DistTravelled2.Value = DistTravelled:Get(UpdatedValue)
end
Update(defaultValue)
DistTravelled:OnUpdate(Update)
local function Update2(UpdatedValue2)
OrbitsComp2.Value = OrbitsComp:Get(UpdatedValue2)
end
Update2(defaultValue2)
OrbitsComp:OnUpdate(Update2)
end)
game.ReplicatedStorage.DistanceRemote.OnServerEvent:Connect(function(plr,speed,orbitspeed)
local DistTravelled = DataStore2("DistanceTravelled",plr)
local OrbitsComp = DataStore2("OrbitsCompleted", plr)
if speed > 100 and speed == speed then
plr:Kick("Yo cheating ain't cool fam! Be fair to your mans!")
elseif speed > -10 and speed <= 100 and speed == speed then
DistTravelled:Increment(speed,defaultValue)
OrbitsComp:Increment(orbitspeed,defaultValue2)
end
end)
game.ReplicatedStorage.DonateRemote.OnServerInvoke = function(player, amount, amount2, recipient)
local rec = game.Players:FindFirstChild(recipient)
local DistTravelled = DataStore2("DistanceTravelled",rec)
local OrbitsComp = DataStore2("OrbitsCompleted", rec)
DistTravelled:Increment(amount,defaultValue)
OrbitsComp:Increment(amount2,defaultValue2)
end
I recommend reading the documentation. I immediately see you using the free model, which is very outdated and not recommended by the documentation at all.
Given that this is a very common problem and the fact that the OP is linked to the free model when it is out of date, wouldn’t it be a good idea to remove links to the free model if it is not updated? Also, likely referencing the post by Alvin_Blox which has his video you pinned which also requires the module by ID which can cause readers to make this mistake again. It might be a good idea to send another reply to the OP rather than a specific reply and mark it as a solution to mark as a “notice”.
(I am using a translator, sorry for mistakes)
Idk someone asked this or not but when you require the module through ID sometime well most of the time it doesn’t work in studio and works perfectly fine in roblox client
Looks like you skipped Kampfkarren and my reply. The free model version is out of date, this is mentioned a lot, get the latest version from GitHub linked in the OP.
K i will try using from github
Dude, use a require
local ds2 = require(id)