i’m probably dumb or something, but how would i look through the data of a player in Datastore Editor (by Crazyman32) with this system?
@Kampfkarren I am having trouble with this. I’m sort of familiar with DataStores, i can do them, however, i am trying to save a lot of values in a table. But i’m not familiar with serializing and deserializing, i’m not sure what they mean either.
I cant find any help anywhere with this. Lets say you have a table with a lot of values stored inside, and its stored into the one data store, how do you go about picking that one value and changing it in the store itself. I understand very well if it was just one value in the store, but i cant seem to wrap my head around saving tables, and many many values. Please help!
As an example i used the basic serialized and deserialized example you gave, and am failing at integrating it… because i dont know how in this case
local SpellDefaultTab = {
["Basic Shield"] = true;
["Orlora"] = true;
["Branda Mirun"] = false;
["Valroc Mirun"] = false;
["Varia"] = false;
["Orlovium"] = false;
["Caecus"] = false;
["Crimbiu"] = false;
["Crimbastu Lackra"] = false;
["Fustama Truvista Livistu"] = false;
["Orlovick"] = false;
["Flithrumar Calivum Brathcavan"] = false;
["Duble Baldadre Hadra"] = false;
["Ible Siezumeum"] = false;
["Blonia Prostagalera"] = false;
["Portalium"] = false;
["Arathalat"] = true;
["Basic Shield Mastery"] = 2;
["Orlora Mastery"] = 2;
["Branda Mirun Mastery"] = 2;
["Valroc Mirun Mastery"] = 2;
["Varia Mastery"] = 2;
["Orlovium Mastery"] = 2;
["Caecus Mastery"] = 2;
["Crimbiu Mastery"] = 2;
["Crimbastu Lackra Mastery"] = 2;
["Fustama Truvista Livistu Mastery"] = 2;
["Orlovick Mastery"] = 2;
["Flithrumar Calivum Brathcavan Mastery"] = 2;
["Duble Baldadre Hadra Mastery"] = 2;
["Ible Siezumeum Mastery"] = 2;
["Blonia Prostagalera Mastery"] = 2;
["Portalium Mastery"] = 2;
["Arathalat Mastery"] = 2;
}
Players.PlayerAdded:Connect(function(Player)
local SpellsStore = DataStore2("SpellsStorage", Player)
local SpellData = Instance.new("Folder")
SpellData.Name = "SpellData"
SpellData.Parent = Player
for statname, statvalue in pairs(SpellDefaultTab) do
if type(statvalue) == 'number' then
local intvalue = Instance.new("NumberValue")
intvalue.Name = statname
intvalue.Parent = SpellData
elseif type(statvalue) == 'boolean' then
local boolvalue = Instance.new("BoolValue")
boolvalue.Name = statname
boolvalue.Parent = SpellData
elseif type(statvalue) == 'string' then
local stringvalue = Instance.new("StringValue")
stringvalue.Name = statname
stringvalue.Parent = SpellData
end
end
SpellsStore:BeforeInitialGet(function(Spells)
local deserialized = {}
for _,SpellId in pairs(Spells) do
for key,value in pairs(SpellDefaultTab) do
if value == SpellId then
table.insert(deserialized, key)
end
end
end
return deserialized
end)
SpellsStore:BeforeSave(function(Spells)
local serialized = {}
for _,SpellVal in pairs(Spells) do
table.insert(serialized, SpellDefaultTab[SpellVal])
end
return serialized
end)
SpellsStore:Get({})
end)
How do i set a value that is inside a table thats stored? Something like this?
local SpellsStore = DataStore2("SpellsStorage", Player)
for key,value in pairs(SpellsStore:Get({})) do
if key == "Orlovium" then
SpellsStore:Set(true)
end
end
There’s nothing special about tables for DataStore2. How would you set the table normally? Just do that then :Set
with the new table.
Make sure this works without [de]serialization, if it does then that means it’s an issue with your BeforeInitialGet/BeforeSave implementations.
It’s a hassle, but it’s possible. From what I remember, this is how you do it.
- Figure out what the data store name is going to be.
A DataStore2 name consists of two parts: KEY/USER_ID
. The key is either the master key if you’re using combined data stores, the normal key otherwise. Let’s say our combined data store key is DATA
and we’re looking for the data of ROBLOX. We would search: DATA/1
.
- Toggle OrderedDataStores and Query.
- Write down the value of the most recent result.
- Turn off OrderedDataStores, and search with the key being what you just wrote down.
oh wait real quick, any specific way of incrementing a value in the table within the datastore?
No, don’t think of tables as anything different in terms of DataStore2.
ok in whichcase how would i increment a specific value in the datastore? just Datastore:Increment(1) how does that find the value in the store?
:Increment
only works if the data value is a number. That’s why as said before:
i understand that it needs to be a number… so what i am to understand is that if the datastore is a table then specific values inside that might be a number cant be incremented with that function. Increment the value outside of it,and reimplement the new table in the store.
Yes. How would you increment the table’s value normally? Whatever it is, do that, then call :Set
on the table–DataStore2 doesn’t care how you set the variable.
I dont need to put anything in the parentheses? or do i put the new table in the Datastore:Set(NewTable)
Again, just set it normally. Tables aren’t anything special.
I’m sorry i feel so dumb not totally understanding how the datastore indexes each name with the value attached into the 1 store. I feel like such a pest rn XD.
Again, don’t think of tables as anything different. When you call :Get()
, it’ll return the table. Do whatever you want with the table. Then call :Set
. I’m not sure what else to say.
local things = thingStore:Get()
things.Something = things.Something + 1
thingStore:Set(things)
that is very helpful thankyou
again i apologize for sounding like a total doofus XD, i guess we all have things we just cant wrap our heads around. You are very patient thank you.
I’m sorry just one more thing: This is what im doing to get the values into the datastore to set the values from the default table, into the datastore…
local SpellsInStore = SpellsStore:Get()
local function UpdateSpellStore(UpdateVal)
for statname,statval in pairs(SpellDefaultTab) do
SpellData[statname].Value = SpellsStore:Get(statname.UpdateVal)
end
end
for i,v in pairs(SpellDefaultTab) do
UpdateSpellStore(v)
end
SpellsStore:OnUpdate(UpdateSpellStore)
end)
basically i want the statname to equal the updateval in the datastore.
Ahh it should be GetTable:({statname = UpdateVal})
local function UpdateSpellStore(UpdateVal)
for statname,statval in pairs(SpellDefaultTab) do
SpellsStore:GetTable({statname = UpdateVal})
local SpellsInStore = SpellsStore:Get()
SpellData:FindFirstChild(statname).Value = SpellsInStore[statname].Value
end
end
this is not working