Cannot Save Information In DataStore

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? I am wanting to save information in my DataStore.

  2. What is the issue?

I am trying to save the information in my DataStore but I am getting this error (as you can see below along with my code), I am unsure how to fix this issue in regards to what I am wanting to achieve.


  1. What solutions have you tried so far? I have looked on the DevForum for any solutions but I have not found any, all of the ones I have found do not help my current issue in regards to what I am trying to achieve.
1 Like

Like it says, it can’t store a Dictionary in the datastore. What you can do is drop all the keys in the Dictionary and downgrade to a table, something a datastore will accept. The order should stay the same, so when you retrieve something like Height, you can use the index 8 on the table. Make sure to also convert all your data into strings first, it’s the most common and easiest way to store the data in datastores.

Quick note, if your firstname and lastname isnt unique, it means that anyone who sets that firstname and lastname can easily overwrite or retrieve that data, even if they aren’t the owners. Alongside this, you can scrap the FirstName and LastName parameters if you still decide to go through with this, as you will already have the names to retrieve the data.

3 Likes

You could maybe try using http service to convert it to a json string and save it as that, and then decode it when you get the data

local http = game:GetService("HttpService")

http:JSONEncode(tablehere)
http:JSONDecode(savedjsonhere)

Something like that ^^
(Not 100% accurate, typing code on a phone is pain)

3 Likes

Table as in

local table = {
height, 
weight, 
etc....
}

or

table.insert

?

I should have said dictionary, sorry. Put your dictionary into the json encode function

1 Like
local dictionary = {
			Player = LocalPlayer,
			FirstName = firstname,
			LastName = lastname,
			Alias = alias,
			Age = age,
			DOB = dob,
			Gender = gender,
			Height = height,
			HairColor = haircolor,
			EyeColor = eyecolor,
			Weight = weight,
			SkinTone = skintone
}

local http = game:GetService("HttpService")
http:JSONEncode(dictionary)

like that?

Should be, sorry for any spelling errors that may exist, typing code on my phone is fun

1 Like

You can actually store dictionary tables in a datastore. You are probably getting the error because you are trying store the player instance in your first line. Instead, you have to convert it to string and store player’s name or player’s userid

1 Like

This most likely was the issue, I’ll check it tomorrow when I can.

This is indeed the reason for the error:

However, I would suggest storing the player’s userId, as a user can change their username with ROBLOX’s name change feature.

1 Like

I fixed this issue but just a general question, how can I get the number of GetAsyncs found in my DataStore? Lets say I stored 3 with the following keys:

  • “HELLO”
  • “WORLD”
  • “HELLO”

How would I find how many have the key “HELLO” or how many it finds with that specific key?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.