Block not spawning

I want a block to spawn whenever someone buys a dev product. However, the block is not spawning when I buy the dev product. I have tried to add prints into the function, but they are not running either. Here is my code in a ProximityPrompt in a part in the workspace.

local MPS = game:GetService("MarketplaceService")

local productID = 2679561268
local ProxPrompt = script.Parent

ProxPrompt.Triggered:Connect(function(plr)
    MPS:PromptProductPurchase(plr, productID)
end)

MPS.PromptPurchaseFinished:Connect(function(player, purchasedProductID, isPurchased)
    if purchasedProductID == productID and isPurchased then
        print(player.Name .. " has purchased a block!")
        
        local newBlock = Instance.new("Part")
        newBlock.Size = Vector3.new(4, 4, 4)
        newBlock.Parent = workspace
        newBlock.CFrame = CFrame.new(80, 80, 0)
        newBlock.Color = Color3.new(
            math.random(),
            math.random(),
            math.random()
        )
    else
        print(player.Name .. " canceled the purchase.")
    end
end)

Probably some weird silent error caused by Event not firing in a Local / Server script.

Try changing RunContext of your script from Legacy to Server or Client, whichever side you need. I had similar issues, that mostly fixed them.

After rewriting my ENTIRE SYSTEM I’ve fixed the issue.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.