Datastore not saving inside studio?

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?

(yes api services are granted)

2 Likes

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.

1 Like

I’ll try looking into that then, I’ve never had an issue with data saving before so this is quite unusual to me. I’ll let you know what comes of it.

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.

2 Likes

What exactly are you doing to save the Data?

What are you trying to save?

I think you mean a Request Error, as in it throws HTTP error when it fails, which can happen from time to time, that shouldn’t be the culprit.

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.

5 Likes

Anyway,

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:

  1. 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
  1. 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.

  2. 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,
image
image

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?

Unfortunately, nothing you mentioned above provided any insight.

image

When going through the customizer, the data assigns properly. But when exiting the test and rejoining, the data fails to save.

I’m confused, you’re trying to store data in attributes and not in raw data?

Yeah, that was like almost 2 years ago.

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.

Yes, it’s way more efficient to manager player data in a game this way.

Unfortunately this isn’t the case. All data is saved as numbervalues, booleans or strings.

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.

1 Like

This feels like a really bad way to store data. It would be much easier and less headache inducing to store data in the already provided Roblox DataStore system. Here’s a video by Alvinblox Roblox DataStore Tutorial - Data Stores & Saving Data - Scripting Tutorial - YouTube

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.

I just used this video a few weeks ago, it worked perfectly with absolutely zero problems whatsoever.

There is no such thing as a Perfect System.

When I say that I mean that it did exactly what I needed to, I don’t see how what they are trying to store couldn’t be saved in one singular table.