Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How would I convert something that a DataStore would be able to read?

I'm currently having issues while developing a script for one of my game's DataStores. I want the DataStore to save values (NumberValues, IntValues, etc.) but I've read on the Wiki:

Unlike Data Persistance, Data Stores cannot save ROBLOX instances directly. For example, calling DataStore:SetAsync("key", Instance.new("Part")) will throw an error. You should write a function that converts the instance to a table or string.

How would I go about converting an instance like a NumberValue or other value to a table or string? Would I need to use tostring()?

2 comments

1

Well, you can save the value of the numbervalue, and when you load the datastore just change the value to what you have saved

0

No, you would not need to use tostring, as that will put a nil value

1 answer

If you want to save a NumberValue or other value to a DataStore, just write NumberValue.Value to the DataStore and then create a new value instance when you retrieve the data.

This discussion is preserved as it was. New answers, comments, and votes are closed.