Hello guys I have problem of saving using DataStore cuz I’m saving the value of the object Value and it’s not working can someone help me.
C o u l d w e s e e t h e s c r i p t ? (Min Characters is fun)
Oh sure but I’m using my phone right now I can’t get the script but I can give an example
Just for example
Local Data = game:GetService ("DataStoreService"):GetDataStore("objSaving")
game.Players.PlayerAdded:Connect(function(plr)
Local obj = instance.new("ObjectValue")
Obj.Parent = plr
Obj.Value = Data:GetAsync(plr.UserId) or nil -- nil for now but when it's not nil and it has obj value it will save
-- sorry I'm using my phone to make this script and you know I make a another function for SetAsync and this most important script
If not obj.Value == nil then
-- clone the value and parent it.
end
end)
Hope this is fine
why did you put if not object == nil i assume you are trying to see if there is no value in it then try removing the nil or the not:
If not obj.Value then
-- clone the value and parent it.
end
end)
or try this:
If obj.Value == nil then
-- clone the value and parent it.
end
end)
But the error say DataStore can’t save the obj value as I understand
Oh i get it now its because You are unable to save objects or object value, only properties of an objects or a values in a datastore
Yes so there ways to solve it?
Actually what kind of object you want to save
I would recommend using datastore2, also using tables instead of ObjValues. Sorry I wasn’t able to help your current dilemma, but I would highly recommend looking into it. I would be able to help you if you provide more infomation/.
A folder that contains more children but when you save the the folder it’s automatic save the children right?
Oh I try it maybe later if I use computer
oh is there values in the children if there is then try saving them as a table with each children’s values
Can I have an example of saving a table?
sure here:
local tab = {SomeValue= 4, AnotherValue = 10};
DataStore:SetAsync(key, tab)
i suggest you try using datastore2 for that
Ok ty I will try to learn about DataStore 2 for now and saving by table