DataStore2 script review

Hello,

I wrote a DataStore2 script to easily load & save data with a function. Is there anything I can do to make this code better?

local DS2 = require(script.Parent:WaitForChild("DataStore2"))

local defaultOwns = false
local defaultWearing = false

game.Players.PlayerAdded:Connect(function(plr)
	-- create folders to store the values
	
	local function createValue(name, parent)
		DS2.Combine("PurchaseDS", name, name.."Wearing")
		
		local dataOwns = DS2(name, plr)
		local dataWearing = DS2(name.."Wearing", plr)
		
		local owns = Instance.new("BoolValue")
		owns.Name = name
		owns.Parent = parent
		
		local wearing = Instance.new("BoolValue")
		wearing.Name = name.."Wearing"
		wearing.Parent = parent
		
		-- load
		if dataOwns:Get() ~= nil then
			owns.Value = dataOwns:Get()
		else
			owns.Value = defaultOwns
		end

		if dataWearing:Get() ~= nil then
			wearing.Value = dataWearing:Get()
		else
			wearing.Value = defaultWearing
		end

		-- save
		owns.Changed:Connect(function()
			dataOwns:Set(owns.Value)
		end)

		wearing.Changed:Connect(function()
			dataWearing:Set(wearing.Value)
		end)
	end
	
	-- use createValue function to create values
end)

Thanks,
p0s_0

DataStore:Get(defaultValue)also returns default value if there was no data to be loaded, rendering this line useless:

Also, there is no point in checking if the data is nil since if you pass the argument for the default value, it will return it if no data existed.

—good:
owns.Value = dataOwns:Get(defaultOwns)