#marketplaceservice + events

5 messages · Page 1 of 1 (latest)

opaque halo
#

in ServerScriptService:

local MarketplaceService = game:GetService("MarketplaceService")

local AnswerBotEvent = game:GetService("ReplicatedStorage"):FindFirstChild("AnswerBotEvent")

game:GetService("ReplicatedStorage"):FindFirstChild("AnswerBotEvent").OnServerEvent:Connect(function(player, bot)
    print("bombo")
    AnswerBotEvent:FireClient(player)
    
    player:SetAttribute("AnswerNPC", bot:GetFullName())
end) 

MarketplaceService.ProcessReceipt = function(receiptInfo)
    if receiptInfo.ProductId == 2816056930 then
        local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
        if player then
            local bot = game.Workspace:FindFirstChild(player:GetAttribute("AnswerNPC"), true)
            if bot then
                local dialog = bot.AnswerNPC.Head.Dialog
                if dialog then
                    task.delay(0.1, function()
                        dialog:Destroy()
                    end)

                    local botMessage = Instance.new("BillboardGui")
                    botMessage.Adornee = bot.Head
                    botMessage.Size = UDim2.new(2, 0, 2, 0)
                    botMessage.StudsOffset = Vector3.new(0, 2, 0)
                    botMessage.Parent = bot.Head

                    local textLabel = Instance.new("TextLabel")
                    textLabel.Size = UDim2.new(1, 0, 1, 0)
                    textLabel.Text = "The answer is: " .. bot.Value.Value
                    textLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
                    textLabel.Parent = botMessage

                    wait(5)
                    botMessage:Destroy()
                end
            end
        end
        return Enum.ProductPurchaseDecision.PurchaseGranted
    end
end```
#

in a localscript, inside a dialog:

local MarketplaceService = game:GetService("MarketplaceService")

local AnswerBotEvent = game:GetService("ReplicatedStorage"):FindFirstChild("AnswerBotEvent")
local bot = script.Parent.Parent.Parent.Parent
local dialog = script.Parent

AnswerBotEvent.OnClientEvent:Connect(function()
    MarketplaceService:PromptProductPurchase(game.Players.LocalPlayer, 2816056930)
end)

dialog.DialogChoiceSelected:Connect(function(player, choice)
    if choice == dialog.No then
        task.delay(0.1, function()
            dialog:Destroy()
        end)
    elseif choice == dialog.Yes then
        AnswerBotEvent:FireServer(bot)
    end
end)```
#

the paths to instances are correct, it won't prompt me the developer product

wind moth
#

Uh

#

What is the problem?