Allow setting datastore saved data to nil

A bug was introduced recently in a place I’m working on that causes new player data to be corrupt and not save properly, but if you played before the update everything is fine – the issue is only present when you haven’t played before and your saved data is being created from the default inventory. Because I can’t set my inventory to nil, I have to test the game on an alternate account, which doesn’t have access to the developer console, and then I have to join that server on my main account on a different computer to view the server log. I could just change the datastore I’m using to SavedData2, SavedData3, etc, but what happens when I need to do that in a published game that has thousands of users with saved data? I can’t do that. This is extremely painful and it would be so much easier to debug if I could just set my own inventory to nil.

There is good reason to clear out datastore keys. We should be able to set their values to nil.

8 Likes

As a possible solution for now, you could set the data to false, so that when you have a check to see if a player’s data is nil, false will also return true

local Data = DataStore:GetAsync("Key") if Data then -- will be false if Data = false or Data = 'nil -- player has data else -- player does not have data, so write new data to it. DataStore:SetAsync("Key",newdata) end

6 Likes

I agree. I made a similar post a couple years ago.

TBH, I wish we had a lot more functionality for the DataStores, such as the ability to write simple queries and stuff, such as you’d find in an ORM DB. Although perhaps that would introduce complexities that some people wouldn’t want to deal with.

3 Likes

Why would you link to such a cringe-y post of mine :frowning:

I agree that we should have the ability to delete data. You can’t argue it could be used for more malicious activity as someone could just set all data keys to -21341234134 instead of deleting. And I don’t think Roblox is going to have a problem paying for less storage.

1 Like

Oops sorry! Meant to link to the beginning of that thread.

2 Likes

Having dealt with httpservice->database and its awesomeness, it’d be neat if we straight up had an actual database for each game. With my first lobby system in The Conquerors, I had to use a database because servers needed to be updated quickly for player joining/leaving/availability and having 5k players spread out in 1000 servers definitely made datastores impossible to use. It was great while it lasted(database shutdown from overuse), it’d be cool if I could’ve done it directly in roblox though

2 Likes

Save each player’s data to a different namespace, then give you, as the developer, the ability to increment the namespace of your data by 1, effectively clearing your data.

i.e. You click “Clear Data” in-game and the namespace of your save data changes from “EchoReaper_save1” to “EchoReaper_save2,” which is blank since you’ve yet to use it.

Or you could get fancy and let yourself define a custom namespace on the fly, to switch between savestates.

1 Like

Version numbers for individual inventories per player is super messy

1 Like

The idea is that you’re the only one with a version number, since you’re the one who needs their inventory cleared on the fly.

1 Like

Having special inventory modes for specific users is even messier

1 Like