Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Prompt Purchase with Dialog?

I've working endlessly to try and form this script but I keep getting stuck in many places. What I'm trying to make is a script that will prompt a purchase of a gamepass to reveal a hint about the game through dialog. So if a user clicks the dialog box, it will ask if they want a hint. If they select yes, it will prompt the purchase of the gamepass, if they buy it, it will reveal the hint in an ending dialog message. However, I obviously don't want the ending dialog message (the hint itself) to be revealed even when they select the choice to prompt the purchase. I'm also wondering if the gamepass can be purchased multiple times? This is only because the user must purchase a hint again to see it again.

This is what I have so far, I'm missing some very important elements, but I'm not sure how to formulate those. I think I have so basics however.

local itemId = 0  ---I'm still yet to make the ID

script.Parent.DialogChoiceSelected:connect(function(player, choice)
	if (choice == script.Parent.Choice1) then		
script.Parent.ClickDetector.MouseClick:connect(function(player)
	game:GetService("MarketplaceService"):PromptPurchase(player, itemId)
end)
	end
end)

1 answer

I am not sure if this is true, but I believe that to hide a dialog is impossible, maybe use Local Parts and Surface Guis.

Anyway, maybe try this script

local itemId = 0  ---I'm still yet to make the ID
local LocalBin = 0 -- 0 = CurrentCamera, 1 = Message

script.Parent.DialogChoiceSelected:connect(function(player, choice)
    if (choice == script.Parent.Choice1) then       
script.Parent.ClickDetector.MouseClick:connect(function(player)
    game:GetService("MarketplaceService"):PromptPurchase(player, itemId)
	if game:GetService("GamePassService"):PlayerHasPass(player, itemId) then
		if LocalBin == 0 then
			local part = game.Workspace.PARTNAMEHERE:Clone() -- Replace PARTNAMEHERE with the part, make sure it is hidden and no one can see it at all
			part.Parent = game.Workspace.CurrentCamera
		else
			local lb = Instance.new("Message", player.Character)
			lb.Name = "LocalBin"
			local part = game.Workspace.PARTNAMEHERE:Clone() -- Replace PARTNAMEHERE with the part, make sure it is hidden and no one can see it at all
			part.Parent = lb
		end
	end
end)
    end
end)

If you want to make a gamepass that you can buy multiple times, use a Developer Product

I hope this helped you!

This discussion is preserved as it was. New answers, comments, and votes are closed.