I want to make a nuke that spawns when you buy a developer product. It is not spawning. I’ve tried switching from PromptProductPurchaseFinished to ProcessReceipt but it still doesn’t work. Here is my localscript in a textbutton:
local MPS = game:GetService("MarketplaceService")
local player = game.Players.LocalPlayer
local nukeEvent = game.ReplicatedStorage.NukeEvent
local nukeProductId = 2707983803
script.Parent.MouseButton1Click:Connect(function()
MPS:PromptProductPurchase(player, nukeProductId)
end)
MPS.PromptProductPurchaseFinished:Connect(function(player, productId, isPurchased)
if productId == nukeProductId and isPurchased then
nukeEvent:FireServer(player, productId)
end
end)
Here is my code in a serverscript in a part of a nuke model which is in Replicated Storage:
local nuke = script.Parent
local nukeModel = nuke.Parent
local nukeEvent = nukeModel.Parent.NukeEvent
local nukeProductId = 2707983803
local Players = game:GetService("Players")
local MPS = game:GetService("MarketplaceService")
local function Ban(Player : Player)
Players:BanAsync({
UserIds = {Player.UserId},
ApplyToUniverse = true,
Duration = 10, -- 10 for testing purposes
DisplayReason = 'You have been banned for one day for attempting to spawn a nuke without buying the product.',
PrivateReason = 'Player tried to exploit a nuke in',
ExcludeAltAccounts = false,
})
end
local function CheckPurchase(player)
local receipt = player:FindFirstChild("ProductPurchaseReceipt")
if receipt then
local productId = receipt.ProductId
if productId == nukeProductId then
return true
end
end
return false
end
nukeEvent.OnServerEvent:Connect(function(player, productId)
if productId == nukeProductId then
if not CheckPurchase(player) then
Ban(player)
end
end
end)