-
What do you want to achieve?
I want to be able to save my dictionary. -
What is the issue?
whenever I save it, it doesnt actually get saved for some reasons. -
What solutions have you tried so far?
Saving currencies and tables work completly fine but this didnt work.
Code
I have tried removing [v.PetID.Value] and it worked fine but I want it to save even like that because thats essential for my pet data
local DS2 = require(game.ServerScriptService.DataStore2)
DS2.Combine("DATA2", "Pets5")
game.Players.PlayerAdded:Connect(function(player)
local PetsData = DS2("Pets5", player)
local playergui = player:WaitForChild("PlayerGui")
local Inventory = playergui:WaitForChild("Main").PetInv.Inventory
local playerid = player.UserId
local DataDictionary = PetsData:Get(nil)
if DataDictionary ~= nil then
for i, v in pairs(DataDictionary) do
print(v["Name"].Name)
end
end
game.Workspace.ChangeIt.Changed:Connect(function()
local PetSaveDictionary = {}
for i, v in pairs(player.Pets:GetChildren()) do
PetSaveDictionary[v.PetID.Value] = {
["Mobility"] = {Value = v.Mobility.Value};
["Name"] = {Name = v.Name};
["Rarity"] = {Value = v.Rarity.Value};
["Equipped"] = {Value = v.Equipped.Value};
["Level"] = {Value = v.Level.Value};
["Locked"] = {Value = v.Locked.Value};
["Multi1"] = {Value = v.Multi1.Value};
["Multi2"] = {Value = v.Multi2.Value};
["PetID"] = {Value = v.PetID.Value};
["Type"] = {Value = v.Type.Value};
["XP"] = {Value = v.XP.Value};
}
end
PetsData:Set(PetSaveDictionary)
end)
end)