Im trying to make a Developer Product that Puts a hat on the player once purchased. The problem is with the Purchase not the hat as im positive the hat works.

MarketplaceService = game:GetService("MarketplaceService")
function MarketplaceService.ProcessReceipt(receiptInfo)
	local player = receiptInfo.PlayerId
	if script.Parent.Parent.Parent.Parent.Parent.Parent.PlayerId == receiptInfo.PlayerId then
		if receiptInfo.ProductId == ######### then
			script.Parent.Parent.val = true
			return Enum.ProductPurchaseDecision.PurchaseGranted	
		end
	end
end 

------

script.Parent.val.Changed:connect(function ()
	if script.Parent.val.Value == true then
		local hatId = #########
		local hat = game:GetService("InsertService"):LoadAsset(hatId):GetChildren()[1]
		hat.Parent = script.Parent.Parent.Parent.Parent.Parent.Character
		
	end
end)