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)
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)