How to proficiently use Datastore 2 with tables?

Hey i’m trying to learn Datastore 2 so far i’ve only learned how to use datastore 2 with no tables basically making a new save for each value. I’m wondering how i can use datastore 2 with tables.

I’ve tried to just make a table like normal and then make a script inside the table and set the value to the datastore but it didn’t work.
local plr = game.Players.LocalPlayer
local data = game.ReplicatedStorage.Data
local Leaderstats = plr:WaitForChild(“leaderstats”)
local DataStore2 = game:GetService(“DataStore2”)
local Stats = DataStore2(“PlayerStats”, plr)

local function Save()
Leaderstats.Level.Value = Stats:Get(“Level”) or 0
end

local function Save()
Stats:Set(“Level”, Leaderstats.Level.Value)
end

plr.ChildAdded:Connect(Save)

plr.ChildRemoved:Connect(Save)

plr.Changed:Connect(Save)

I expect the table to be saved into the datastore2 but it doesn’t work.

Data Store 2 does not support saving tables. You will have to serialize your table into a string before saving it into Data Store 2, and deserialize it back into table when you’re reading it from Data Store 2.
If you are using Roblox’s default serializer, you can use serialize and deserialize (located in DataModel) to serialize and deserialize your tables.

It supports tables. Also just tried saving a table, and it worked.