I have a datastore framework that I’ve been using for quite some time now, and it’s been working without flaw. However when creating a character creator today, I realize that my data isn’t saving?
Can you not save data when testing inside of studio?
DataStoreService is accessible inside Roblox Studio and Roblox, you may have a data error. Try printing your entire DataStore (unless you’ve already opened your game to the public) to see if it still holds your data, if not you may need a failsafe method incase data fails to save/load again.
Sometimes, very rarely, Roblox will mess up with save data and throw the whole system out of balance if you don’t have a way to overwrite the data manually or by a failsafe method.
The DataStore will not save if the server closes and you are just using players.PlayerRemoved.
As such, you use game:BindToClose(function) to avoid this.
local players = game:GetService("Players")
local funtion playerRemoved(player) -- whatever your saving function is
game:BindToClose(function()
for i, player in pairs(players:GetChildren()) do
playerRemoved(player)
end
end)
You also might notice lag while it attempts to save inside of Studio using this method. Personally, I use the run service to only make the BindToClose work when it is on an actual server and I just edit my values.
DataStoreService works in studio as stated above, it however depends on how you are managing it, if you are denying Service from the ModuleScript if the Game is running in Studio, that might be why, There are some things people do to prevent others from using the Module, which can be the following:
Checking for a Creator
People check for a Creator to see if the Game is Published or not using game.CreatorId, If there is no creator, that means the game is unpublished, as compared to a game thats published, it will print either a Player’s UserId, or a GroupId, People check it like so:
if game.CreatorId == 0 then -- If there is no creator
warn("Game is not Published, Data will not Save!")
else
print("Game Published, Data will Save!")
end
Checking the GameId / PlaceId
Like with CreatorId, GameId can be used to check if a game is Published or not, Along with PlaceId, these are unique identifiers to the Game, and Place.
RunService:IsStudio()
This function in RunService allows you to check if the Environment the Script is running in is in Studio or not, with this we can check if our code is running in studio, and if so, we can deny Service for the ModuleScript, like so:
local RunService = game:GetService("RunService")
if RunService:IsStudio() then -- if the Script is running in Roblox Studio
warn("Game running in Studio, Data will not Save!")
else -- if not
warn("Game running in a Server, Data will Save!")
end
So my datastore utilizes ROBLOXs new attribute system,
Creating a new userid folder for each player.
Now generally, saving is pretty simple.
The backend uses standard datastore service grabs
EDIT: Beforehand, the only data I really saved was how much Yen the player had, and if they already completed the tutorial (firsttime value). But now with this character creator, I’ve added a ton more values. Maybe the datastore is overloaded?
No, DataStores can save about 4 megabytes of Data, this should be way less than that as 1 character below the first 128 unicode points are 1 byte, and 4 megabytes is roughly 4 million bytes (or characters)
May not be what you’re doing but:
If you are trying to Save Something like an Instance, you need to save the Data of the Instance, and not the Instance itself.
You should Also make sure that the Data is being updated to your DataStore, maybe you can hold Session Data for each player, and update them accordingly.
The Data is probably Stored somewhere else, The Data is likely being added into the Attributes, and the game is detecting the changes to them, and updating the Players Session Data according to that new Data.
This is 4 years ago, a lot of the info in this is likely outdated as Attributes was only Introduced 2 years ago, and New Methods were likely Discovered in that time.