I’m somehow getting this error? pls help
How well is datastore2 able to handle a value that changes quickly over a period of time, that may need to save? I am making a sort of resource managing game, and the resources may change quickly. I want these resources to save.
Hi there, my game has been using DataStore2 for a while now but we implemented a “quests” feature which saves a table and has worked for a while. On release, players were being given random default values their first time in the game which showed them having made very odd progress on quests. Any ideas how we could be calling the wrong data?
local DataStoreService = game:GetService("DataStoreService")
local datastore = DataStoreService:GetDataStore("Coins")
I have found a major issue with the latest version of DataStore2.
When loading multiple DataStores with multiple players, it takes a while for everything to load.
Here is a screenshot from a YouTube video with 6 players inside.
I have a Dev Build of the next update for my game that uses ProfileService and the issues that DataStore2 have are nonexistent…
Here is an example of what the DataStore2 scripts looked like:
local DataStore2 = require(game:GetService("ServerScriptService").DataStore2)
local CombinedDataStore = DataStore2.Combine("PlayerData", "PlayerDataBackup")
local DefaultTable = {
["MultiplayerWins"] = 0,
["BattleWins"] = 0,
["IsWinObby"] = false,
["IsLikedGame"] = false,
["VersionPlayed"] = "4.0"
}
game:GetService("Players").PlayerAdded:Connect(function(Player)
local DataStore = DataStore2("PlayerData", Player)
local DataTable = DataStore:GetTable(DefaultTable)
local Data = Instance.new("BinaryStringValue")
Data.Name = "PlayerData"
Data.Parent = Player
for DataType, Value in pairs(DataTable) do
Data:SetAttribute(DataType, Value)
end
for DataType, Value in pairs(DefaultTable) do
if not Data:GetAttribute(DataType) then
Data:SetAttribute(DataType, Value)
end
end
Data.AttributeChanged:Connect(function()
local DataToSave = {}
for Map, Value in pairs(Data:GetAttributes()) do
DataToSave[Map] = Value
end
DataStore:Set(DataToSave)
end)
end)
I expect 8 to run at the same time when a player joins. It loads instantly just fine with 1 player, but when 2 or 3 join, data takes a long time to load.
I would love to work with you to fix this major DataStore2 issue, I will give you all the info that you need to fix the issue.
Someone having error
DataStore2 doesn’t save until the player leaves the game. It will be fine.
Don’t worry I got it to fix. I messaged the other scripter and he forgot to add something, so all you would have to do it check if it doesn’t exists then add it to the data store.
Any idea why this error happens? Ever since I replaced some gets with gettable this happens and I think this throws an error and prevents the rest of the script from running
Does anyone know how I can save attributes in datastore2 ?
If someone has an idea regarding this problem/bug, please reply. It is eating my brains atm.
Could this be used for leaderboards or would you need a seperate data store for that?
use OrderedDataStore Service for LBs
You cant, just litreally save the value in the data store and then in the script get that value and apply it onto the attribute
What is the 100 part, I’m confused on how DataStore:Get() parameters work. If anyone could ELI5 that would be great, thank you.
That’s the default value if none exists in the data store.
Default Value’s most likely 0, or nil
No, what they mean is the input value (100 in this case) is the user-set default value.
Rather than setting the default and then overriding it if there is existing data (as is done with regular datastores), this checks if there is data first and sets the value to whatever your inputted value is in the event of no data
I see, I thought they were asking what the manually set data was for, I should’ve looked more into the message before answering, that’s for the correction <3