Problems with :Connect

Greetings, I’m currently trying to pass more than one argument in a :Connect() function, but once I retrieve the second argument and print it, it says nil. Any help? Am I doing this correctly.

for i,v in pairs(productsFolder:GetChildren()) do

if not productsExample.Parent:FindFirstChild(v.Name) then

local newGui = productsExample:Clone() -- Creates available products for purchase GUI
newGui.Parent = productsExample.Parent
newGui.Visible = true
newGui.Name = v.Name
newGui.ProductName.Text =
newGui.Price.Text = "$" .. prices.Stores[storeName][v.Name].Price

newGui.Minus.MouseButton1Click:Connect(AddPurchase, newGui.Name)
newGui.Plus.MouseButton1Click:Connect(RemovePurchase, newGui.Name)


Connect can only accept one argument, the function that must be called when the rbx script signal is fired, what are you trying to do?

If you want to pass in the second argument as a parameter to the function then do this:

newGui.Minus.MouseButton1Click:Connect(function() AddPurchase(newGui.Name) end)
newGui.Plus.MouseButton1Click:Connect(function() RemovePurchase(newGui.Name) end)

or you can use a Higher ordered function like this

local function AddPurchase(Param)
    return function()
        --put the code you have for the function here

--then just do this

The second solution worked just fine, thanks for the tip.