local datastore2 = require(1936396537)

datastore2.Combine("Masterkey","Inventory")

local default = {}
local invtable = {}

function addItem(plr,item)
	local InventoryStore = datastore2("Inventory", plr)
	table.insert(invtable, item)
	default = invtable
end

game.Players.PlayerAdded:Connect(function(plr)
	local bankItems = plr:WaitForChild("PlayerGui"):WaitForChild("Bank"):WaitForChild("BankedItems")
	
	local bankDatastore = datastore2("Inventory",plr)
	bankDatastore:SetBackup(5)
	local invtable = bankItems:GetChildren()
	
	local function invUpdate(newValue)
		default = invtable
	end
	
	invUpdate(default)
	bankDatastore:OnUpdate(invUpdate)
	
	bankItems.ChildAdded:Connect(function(child)
		invUpdate(child.Parent:GetChildren())
	end)
end)

I'm not sure if I'm doing this correctly, I only want to save the inventory (which is created with :GetChildren() of the 'bankeditems' folder)

I'm still new to this datastore2 stuff, so it's hard to understand stuff like this.