Datastore is Saving Things in the wrong Format

Hello! My datastore for saving pets is saving things incorrectly

when I save it like this:

	for i,v in pairs(game:GetService("ReplicatedStorage").OwnedPets[player.UserId]:GetChildren()) do
				if v then
					local derpystatus = false
					if v:FindFirstChild("IsDerpy") then
						derpystatus = true
					end
					table.insert(petstosave,v.Name)
					petstosave[v.Name] = {["PetId"] = v.CloneFolder.PetId.Value, ["IsShiny"] = derpystatus}
				end
			end

It prints the table properly
however, when I try to access it upon rejoin, using this:

			if petsdata:GetAsync(player.UserId) then
				for petname, petData in pairs(petsdata:GetAsync(player.UserId)) do
					print(petname)
					print(petData)

It prints the PetId as the petname, and the petsname as petdata.
Yet it should print petname as the petname (Key) for the datastore and petData as the table showing the PetId and IsShiny

The pets save, but it saves in the wrong format and that whole table with the IsShiny and PetId is gone.

Maybe try removing table.insert(petstosave,v.Name)

1 Like