okay thank you. Would this be fine to call immediately before I teleport them with TeleportService? Or should I save & lock the player into a teleport after a few seconds of saving?
Hello! I have a quick question, if I want to save a lot of data, for example an array, should I use Combined DataStore instead of GetTable method?
local Template = GetDataTemplate() -- returns all keys of DataTemplate table who i want to save
self.DataStore = DataStore2.Combine(DataStoreName,unpack(Template))
for i,v in ipairs(Template)do
self.Data[i] = DataStore2(i,Player):Get(DataTemplate[i]) -- Default Value of each key
end
To be more specific, my question is if this is good practice.
Thanks for reading, I would appreciate an answer!
How do you insert the latest folder into Roblox Studio?
it doesnt save i only have one key though but i still did datastore2.Combine(“AllData”) because I save it in a dictionary. I also have SaveOnStudio value true in server storage. please help
Say if I make a tool for a simulator or make a developer product instead of saying: player.leaderstats.Points.Value, would I say: Increment(“points”, player)?
Idk why this characters script isn’t saving. It saves the characters, but not the points. I get the message saying that it did save, but its not. Help please?
local DataStore2 = require(game:GetService("ServerScriptService").DataStore2)
local CombinedDataStore = DataStore2.Combine("Characters", "CharactersBackup")
local MarketplaceService = game:GetService("MarketplaceService")
local DefaultTable = {
Characters = {""},
EquippedCharacter = "",
Leaderstats = {{Points = 50}}
}
game:GetService("Players").PlayerAdded:Connect(function(Player)
local DataStore = DataStore2("Characters", Player)
local DataTable = DataStore:GetTable(DefaultTable)
local Data = Instance.new("Folder")
Data.Name = "Characters"
Data.Parent = Player
for DataType, Value in pairs(DataTable.Characters) do
local Character = Instance.new("BinaryStringValue")
Character.Name = Value
Character.Parent = Data
end
Player:SetAttribute("EquippedCharacter", DataTable.EquippedCharacter)
for DataType, Value in pairs(DefaultTable.Characters) do
if not Data:GetAttribute(DataType) then
Data:SetAttribute(DataType, Value)
end
end
local changing = Instance.new("BoolValue")
changing.Name = "ChangingChar"
changing.Parent = Player
local Leaderstats = Instance.new("Folder")
Leaderstats.Name = "Leaderstats"
Leaderstats.Parent = Player
local Points = Instance.new("IntValue")
Points.Name = "Points"
Points.Value = DataTable.Leaderstats.Points
Points.Parent = Leaderstats
local function SaveData()
local DataToSave = {
Characters = {},
EquippedCharacter = "",
Leaderstats = {{}}
}
for Number, Value in pairs(Data:GetChildren()) do
DataToSave.Characters[Number] = Value.Name
end
DataToSave.EquippedCharacter = Player:GetAttribute("EquippedCharacter")
DataStore:Set(DataToSave)
end
Data.Changed:Connect(SaveData)
Player:GetAttributeChangedSignal("EquippedCharacter"):Connect(function()
SaveData()
end)
Points.Changed:Connect(SaveData)
GetCharacter(Player)
end)
Also, the functions in here are functions to load the character.
Could you explain some ways to do this without session locking? Including methods outside of roblox, since I couldn’t find much on it.
I recently came across a bug which allows players to dupe in my game.
If a player crashes themselves their data wont save. (using the newest version too)
Should I use DataStore2.SaveAll on player removing to prevent this?
You’re bad on luck, DataStore2 doesn’t handle data duplications primarily because of no session lock features. Any of the methods you mentioned won’t work, and if you really want a proper data management which handles many nasty edge cases, I highly recommend using ProfileService.
It would be very tedious to change all my code to introduce profileservice.
yo do u know how we could see if the player has played in another datastore like before a datawipe
so like
if (player has played in another save) then
– do the thing i want to do
end
Could there still be entries in the DataStore that are not listed in the OrderedDataStore due to a failure to write to the OrderedDataStore?
Maybe. Swapping the two RemoveAsync should clear that worry though.
Hey. I really enjoy using your convenient module.
However, I found this a little hard to understand, as I’m using an updated version of the plugin. I’m using a combined data store, and I need to edit one of its values.
I know what my key is, and I toggled the correct settings. This is what I found:
I’ve noted this value down, but I’m not sure where to enter this information.
Could you help? Thanks!
Hello, I don’t understand Luay very well, can you tell me how to configure the module so that it automatically sends data to the client.
Just attach it to a RemoteEvent
Question what If I need to send something from a local script but can’t cause you can Require the module from the client it always says “DataStore2 isn’t a valid member of ServerScriptService”
Quick question:
How would I loop through all of the datastores under a certain player?
Why it doesn’t make sense, my game is slowing down a lot because of onUpdate
(sorry for such a long period of time)
My game when player leave it save but when game shutdowned it doesnt save why? I used the latest datastore2 module from github, i tried to use SaveAll loop make more broken like when the server getting slower when leave it wont save the data