#prompt developer product after dialog choice

101 messages · Page 1 of 1 (latest)

pallid halo
#

local script:

local MarketplaceService = game:GetService("MarketplaceService")

local bot = script.Parent.Parent.Parent.Parent
local dialog = script.Parent

dialog.DialogChoiceSelected:Connect(function(player, choice)
    if choice == dialog.No then
        task.delay(0.1, function()
            dialog:Destroy()
        end)
    elseif choice == dialog.Yes then
        player:SetAttribute("AnswerNPC", bot:GetFullName())
        MarketplaceService:PromptProductPurchase(game.Players.LocalPlayer, 2816056930)
    end
end)```


it wont prompt
#

server script:

local MarketplaceService = game:GetService("MarketplaceService")

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()
                    player:SetAttribute("AnswerNPC", nil)
                end
            end
        end
        return Enum.ProductPurchaseDecision.PurchaseGranted
    end
end```
#

please its urgent

tidal kayak
pallid halo
#

can you wait till i do that

#

please

tidal kayak
#

also wtf is DialogChoiceSelected

#

are you using a custom signals module?

#

I dont remember that being a RBXsignal

pallid halo
#

wha

#

it is

#

atleast chatgpt said so, i've asked him to teach me dialogs

#

this code is written by me btw

tidal kayak
#

guh

#

yea I dont think that exists

#

wait no

#

might exist actually

pallid halo
#

the localscript didnt even work

#

OH

tidal kayak
#

oh it does

pallid halo
#

BECAUSE IT IS IN WORKSPACE??

#

.

tidal kayak
#

dialogue instance is so silly

pallid halo
#

ya

tidal kayak
pallid halo
#

chatgpt said

#

localscripts dont work in workspace

#

it didnt even print localscript working for me

#

but then

tidal kayak
#

oh

pallid halo
#

how will i capture the dialogchoiceselected

tidal kayak
#

thats true

#

turn it into a

pallid halo
#

it only works on localscripts

tidal kayak
#

script

#

but

#

runcontext local

#

thats a property

pallid halo
#

whats runcontext

#

or even a runcontext local?

tidal kayak
#

yes

#

that

#

should work

pallid halo
#

oh my days

#

runcontext is overpowered

#

thank you, it does prompt me

#

buttttttt the billboard isnt kinda working

#

probably it's too small, i don't know

tidal kayak
#

billboard?

pallid halo
#

ya

#

lemme remind you of where it is

#
local MarketplaceService = game:GetService("MarketplaceService")

MarketplaceService.ProcessReceipt = function(receiptInfo)
    if receiptInfo.ProductId == 2816056930 then
        print("bought")
        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()
                    player:SetAttribute("AnswerNPC", nil)
                end
            end
        end
        return Enum.ProductPurchaseDecision.PurchaseGranted
    end
end```
#

here

#

oh

#

wait

#

i have parented them wrongly

#

sec

#

its saying that the bot's path is invalid

#

are you still here 😭

tidal kayak
#

you set that attribute on the client

#

which doesn't replicate

#

fireserver with a remote event and set it on the server

pallid halo
#

oh

#

i didnt really learn remote events yet

tidal kayak
#

client doesn't replicate to server

pallid halo
#

alright, thanks for letting me know

#

i will try to make a remote rn

pallid halo
#

how do i transfer it to the purchased function

tidal kayak
#

oh

#

do a OnServerEvent

pallid halo
#

script with runcontext being local

tidal kayak
#

and set the attribute there

#

in a serverscript ofcourse

pallid halo
#

uhh what

#

i'm thinking of doing something like this

#

wait a bit

pallid halo
tidal kayak
#

ask chatgpt

#

ig

pallid halo
#

pleaseee

#

i dont know how to do the attribute way you told me to

#

you said client doesnt replicate to server

#

oh wait

tidal kayak
#

connect the onserverevent outside

#

of the uh

#

yes

#

like that

pallid halo
#

i guess i will have to name it's name, not add a billboard

#

i have to go though, school

#

see ya, thanks for helping