NotZylon
(shiesty)
March 19, 2021, 11:28pm
#1
Im getting this error and im not sure what it means can someone help me and tell me what it means?
local inventoryString = Instance.new("StringValue")
InventoryStore:OnUpdate(function(decodedData, player)
inventoryString.Value = decodedData --Error here
2 Likes
StringValues
are intended to store strings
– the error is indicating that “decodedData” is an Instance
, which cannot be stored inside of a StringValue. An ObjectValue
would be utilized to store a reference to an Instance, instead.
However, I’m not sure what the use case for this is, so keep in mind that there may be better alternatives for what you’re trying to do.
1 Like
NotZylon
(shiesty)
March 19, 2021, 11:39pm
#3
what is a better alternative instead of decodedData?
Jystor
(Juster)
March 19, 2021, 11:40pm
#4
Try tostring(decodedData), this will convert decodedData to a string
NotZylon
(shiesty)
March 19, 2021, 11:41pm
#5
Jystor:
tostring(decodedData)
I tried that but it says this now, i can just make a new post about it, but i think it would be spam but im not sure
Jystor
(Juster)
March 19, 2021, 11:45pm
#6
what type is decodedData ?
Check using print(type(decodedData) – If it’s not a string then It wouldn’t work
RFL890
(RFL890)
March 19, 2021, 11:49pm
#8
do
print(decodedData.ClassName)
tell me the output
RFL890
(RFL890)
March 19, 2021, 11:51pm
#10
Ohhhh you’re trying to save instances to a datastore?
NotZylon
(shiesty)
March 19, 2021, 11:51pm
#11
i can’t use datatstore2?
you can you just can’t store instances
NotZylon
(shiesty)
March 19, 2021, 11:53pm
#13
oh, how would i save this type of stuff then?
Since you can’t save the object itself into a DataStore, you could store some data that’ll be used to identify the item, such as its name.
Here’s a fantastic thread which covers this topic:
This article is the answer to the famous question “How to save objects using Datastore” and many other ways to word it.
If you played with Datastore for enough time, I think you already know that Instances such as parts and models ect. can’t be simply saved using :SetAsync(), which makes it hard to save objects. Most people, with games that are supposed to have slots and stuff on them that you want to save, get stuck when doing this, although, I think finding a way to go over this is quite eas…
RFL890
(RFL890)
March 19, 2021, 11:55pm
#15
my man, I was just about to post that lol
1 Like
NotZylon
(shiesty)
March 20, 2021, 12:15am
#16
what if my item is a model?
A Model
is still an Instance, which means that some form of serialization would be required.
Any object that you create using the Instance.new()
function, is literally an Instance as the function itself states
RFL890
(RFL890)
March 20, 2021, 12:34am
#19
That’s not true. There are NotCreatable objects.
1 Like