I got a problem with dev products

can i show the prompt from a server script called by a local script with a remote event?

and if yes, ill send script to fix

2 Likes

explain more, you want a proximityprompt to work on the server but called by the local by an event?

1 Like

by prompt i mean the dev product purchase prompt

1 Like

ohh i sorry im too tired today

1 Like

ok so whats the final answer???

1 Like

show your script then i will try to help, helped a few people today and feel like a hero.

1 Like

– Server Script (ServerScriptService)
local MarketplaceService = game:GetService(“MarketplaceService”)
local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local Players = game:GetService(“Players”)
local PurchaseRequest = ReplicatedStorage:WaitForChild(“dev_products”):WaitForChild(“DP2”)

local productID = 1702918929 – Replace with your actual developer product ID
local rewardCash = 50000 – The amount of cash to give to the player after a successful purchase

– Function to process the receipt when a player buys the developer product
local function processPurchase(player, productId)
– Only reward if the product ID matches
if productId == productID then
– Ensure the player has leaderstats and a “Cash” value
if player:FindFirstChild(“leaderstats”) then
local cash = player.leaderstats:FindFirstChild(“Cash”)
if cash then
cash.Value = cash.Value + rewardCash
end
end
end
end

– Function to handle the player’s purchase request
local function onPurchaseRequest(player, productId)
– Debugging print statement to check product ID
print("Received purchase request for product ID: " … tostring(productId)) – Debugging print

-- Ensure that productId is valid and not nil
if not productId then
	warn("Invalid product ID!")
	return
end

-- Attempt to prompt the purchase
local success, message = pcall(function()
	MarketplaceService:PromptProductPurchase(player, productId)
end)

if not success then
	warn("Error in prompting purchase: " .. message)
end

end

– Connect the RemoteEvent to handle the purchase request
PurchaseRequest.OnServerEvent:Connect(function(player, productId)
– Ensure that productId is passed correctly
if productId == productID then
onPurchaseRequest(player, productId)
else
warn(“Received invalid product ID from player:”, player.Name)
end
end)

– Process the purchase receipt once it’s completed
MarketplaceService.ProcessReceipt = function(receiptInfo)
local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)
if player then
processPurchase(player, receiptInfo.ProductId)
end
– Grant the purchase or deny it
return Enum.ProductPurchaseDecision.PurchaseGranted
end – server script actived by a remote event active by a local script

2 Likes

you can show the prompt to buy a gamepass , developer product and subscription from any script

1 Like

what is exactly not working in your script ?

1 Like

ok ill show you, words words words

2 Likes


firing remote event from local script,

when i click:
image

nothing appears.

error:

dev_products_money2 is the script i sent before (server script)

2 Likes

just prompt the purchase from the local script directly

2 Likes

but then idk how to reward cash correctly after purchasing

1 Like

and i also dont know what to put in local one

2 Likes

the problem is you are not passing the product id in FireServer function , and you have a check if it is equal to the id , you are not passing any thing so it compares if the player == the product id and it is not , the OnServerEvent connection gives you the player who fired the event and any thing you passed in FireServer

2 Likes

call PromptProductPurchase directly
cool text because of the characters limit

1 Like

can you please do the script for me plsssssssssssssssssssssssssssssss

1 Like
workspace.GAMEPASSES1.SurfaceGui.shop.zFrame.g10k.image.a4.MouseButton1Click:Connect(function()
MarketPlaceService:PromptProductPurchase(Player , Yourproduct id)
end)
2 Likes

this should prompt the player to buy the developer product

k thanks really much but, now how can the server script work?

1 Like