Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Dev Product function expects code to use "end" when using "return"?

Asked by 5 years ago

Hi, I am confused why the return statement does not work for this function, the error Studio gives me is:

"Expected 'end' (to close 'then' at line 12), got '?' " (The Return Statement)

local link = game:GetService("MarketplaceService")
deb = 0


script.Parent.ClickDetector.MouseClick:Connect(function(plr)
local marketId = 377473848 --ID OF YOUR DEVELOPER PRODUCT  
if deb == 0 then
    deb = 1
    link:PromptProductPurchase(plr,marketId)
    link.ProcessReceipt = function(receiptInfo)
    if plr.userId == receiptInfo.PlayerId then
        if receiptInfo.ProductId == marketId then
        local megalodon = game:GetService("ServerStorage").Megalodon:Clone()
        megalodon.Parent = game.Workspace
        megalodon:MakeJoints()
        megalodon:MoveTo(workspace.SharkPoint2.Position)
        wait(1)
    deb = 0
    return Enum.ProductPurchaseDecision.PurchaseGranted? -- <-- RETURN IS HERE
end
end
end
end
end)

1 answer

Log in to vote
1
Answered by
popeeyy 493 Moderation Voter
5 years ago

You had one too many ends. You should indent your code so you can see if you have the correct amount of ends. Your code should look like this:

local link = game:GetService("MarketplaceService")
deb = 0


script.Parent.ClickDetector.MouseClick:Connect(function(plr)
    local marketId = 377473848 --ID OF YOUR DEVELOPER PRODUCT  
    if deb == 0 then
            deb = 1
        link:PromptProductPurchase(plr,marketId)
            link.ProcessReceipt = function(receiptInfo)
            if plr.UserId == receiptInfo.PlayerId then
                if receiptInfo.ProductId == marketId then
                    local megalodon = game:GetService("ServerStorage").Megalodon:Clone()
                    megalodon.Parent = game.Workspace
                    megalodon:MakeJoints()
                    megalodon:MoveTo(workspace.SharkPoint2.Position)
                     wait(1)
                 deb = 0
                    return Enum.ProductPurchaseDecision.PurchaseGranted
            end
        end
    end
end)
0
thanks homie GlobeHousee 50 — 5y
Ad

Answer this question