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

I am making a nuke developer product but the prompt wont let the player buy it?

So for my game I have a nuke developer product that allows you to purchase a developer product for a nuke to spawn in the map and kill all the players.

But when I click the button it doesn't let me purchase it so it happens..

local mps = game:GetService("MarketplaceService")
local gamepass_id = 1087678048

script.Parent.MouseButton1Click:Connect(function()
	local player = game.Players.LocalPlayer
	mps:PromptGamePassPurchase(player, gamepass_id)
end)

mps.PromptGamePassPurchaseFinished:connect(function(player, id, purchased)
	if id == gamepass_id and purchased then
		game.StarterGui.ScreenGui.TextButton.Visible = false
		game.Workspace.countdown.Disabled = false
		game.workspace.nuketime.Playing = true
		game.workspace.nuketime.Looped = true
		wait(16)
		local nukerO = game.ReplicatedStorage.Nuke:Clone()
		nukerO.Parent=game.Workspace
		game.Workspace.nuketime.Playing = false
		game.Workspace.nuketime.Looped = false
		wait(30)
		game.Workspace.countdown.Disabled = true
		game.StarterGui.ScreenGui.TextButton.Visible = true
	end
end)

could I have some help?

2 comments

1

wouldnt you use promptproductpurchase instead of gamepass purchase because you're making a product not gamepass

0

When trying to purchase it I get this error "Your purchase failed because something went wrong. Your account has not been charged. Please try again later." and be aware I am on the actual roblox game itself not studio.

1 answer

It is actually so simple all I did was overthink.

on line 6 all I had to do was replace PromptGamepassPurchase with PromptProductPurchase, and I was all set!

local mps = game:GetService("MarketplaceService")
local gamepass_id = 1087678048

script.Parent.MouseButton1Click:Connect(function()
	local player = game.Players.LocalPlayer
	mps:PromptProductPurchase(player, gamepass_id)
end)

mps.PromptGamePassPurchaseFinished:connect(function(player, id, purchased)
	if id == gamepass_id and purchased then
		game.StarterGui.ScreenGui.TextButton.Visible = false
		game.Workspace.countdown.Disabled = false
		game.workspace.nuketime.Playing = true
		game.workspace.nuketime.Looped = true
		wait(16)
		local nukerO = game.ReplicatedStorage.Nuke:Clone()
		nukerO.Parent=game.Workspace
		game.Workspace.nuketime.Playing = false
		game.Workspace.nuketime.Looped = false
		wait(30)
		game.Workspace.countdown.Disabled = true
		game.StarterGui.ScreenGui.TextButton.Visible = true
	end
end)

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