Developer Product Help!

You can write your topic however you want, but you need to answer these questions:
I’m trying to make a purchase prompt to show up when someone joins the game. There’s an issue of course!! My code is perfectly fine no errors everything prints out my ID is correct, but nothing works still?

I need help! please and thank you :slight_smile:

local Players = game.Players
local productID = 1427383861
local MarketplaceService = game:GetService("MarketplaceService")


Players.PlayerAdded:Connect(function(player)
	MarketplaceService:PromptProductPurchase(player, 1427383861)
end)



print("Worked")

It’s likely because the player is still loading into the game when the prompt opens. You can add a delay:

local Players = game.Players
local productID = 1427383861
local MarketplaceService = game:GetService("MarketplaceService")


Players.PlayerAdded:Connect(function(player)
    task.wait(.5) -- wait 0.5 seconds
	MarketplaceService:PromptProductPurchase(player, 1427383861)
end)

print("Worked")
3 Likes

Thank you for responding. :slight_smile:

Unfortunately, though it didn’t work…I’m guessing it’s a Roblox problem or it’s my ID I don’t know.

1 Like

are you doing this on a local script or a server script?

2 Likes

I made a script in ServerScriptService.

i think i found the issue with the script, add .UserId to the player on the promptproductpurchase

2 Likes

my bad, don’t do that but i think i found the issue

2 Likes

Like This? if so, I got an error.

Edited the script a bit. try this

local Players = game:GetService("Players")
local productID = 1427383861
local MarketplaceService = game:GetService("MarketplaceService")


Players.PlayerAdded:Connect(function(player)
    task.wait(0.5)
	local hasTheGamePass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, productID)	
	if hasTheGamePassPass then		
		print(player.Name.." owns the gamepass")
	else
        print(player.Name.." doesn't own the gamepass. Prompting purchase.")
		MarketplaceService:PromptGamePassPurchase(player, productID)		
	end	
end)

print("Worked")

is it a gamepass or a developer product you’re prompting?

image

Developer Product

ok, give me a few minutes to edit the script.

1 Like

Use this.

local Players = game:GetService("Players")
local productID = 1427383861
local MarketplaceService = game:GetService("MarketplaceService")


Players.PlayerAdded:Connect(function(player)
    task.wait(0.5)
    MarketplaceService:PromptProductPurchase(player, productID)
end)

print("Worked")

I almost forgot to tell you this but did you forget to turn on http requests in the game settings? that may be what is causing the issue.

1 Like

:eyes:

Didn’t turn that on…was I supposed too?

yes, try it and see if that fixes the issue.

1 Like

Nope, still didn’t work (while using your script too)

Try this:

local Players = game:GetService("Players")
local productID = 1427383861
local MarketplaceService = game:GetService("MarketplaceService")


Players.PlayerAdded:Connect(function(player)
	
	player.CharacterAdded:Connect(function(character)
		MarketplaceService:PromptProductPurchase(player, 1427383861)
	end)
end)

print("Worked")

I just tested it and it works.

Using the character added event ensures the player is loaded into the game before prompting the purchase.

3 Likes

Thank you very much it worked :happy2:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.