function DataStore.Save(K)if not K.valueUpdated then return end if K.backup then return end if K.value~=nil then local k=clone(K.value)if K.beforeSave then local W,A=pcall(K.beforeSave,k,K)if W then k=A else return end end if not Verifier.warnIfInvalid(k)then return warn("\073\110\118\097\108\105\100 \100\097\116\097 \119\104\105\108\101 \115\097\118\105\110\103")end local W,A=K.savingMethod:Set(k)if not W then end for W,A in pairs(K.afterSave)do local d,T=pcall(A,k,K)if not d then end end end end
--[[**
	<description>
	Saves the data to the data store. Called when a player leaves.
	</description>
**--]]
function DataStore:Save()
	if not self.valueUpdated then
		--warn(("Data store %s was not saved as it was not updated."):format(self.Name))
		return
	end

	if self.backup then
		--warn("This data store is a backup store, and thus will not be saved.")
		return
	end

	if self.value ~= nil then
		local save = clone(self.value)

		if self.beforeSave then
			local success, newSave = pcall(self.beforeSave, save, self)

			if success then
				save = newSave
			else
				--warn("Error on BeforeSave: "..newSave)
				return
			end
		end

		if not Verifier.warnIfInvalid(save) then
			return warn("Invalid data while saving")
		end

		local success, problem = self.savingMethod:Set(save)

		if not success then
			-- TODO: Something more robust than this
			--error("save error! " .. tostring(problem))
		end

		for _, afterSave in pairs(self.afterSave) do
			local success, err = pcall(afterSave, save, self)

			if not success then
				--warn("Error on AfterSave: "..err)
			end
		end

		--print("saved "..self.Name)
	end
end
