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
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
explain more, you want a proximityprompt to work on the server but called by the local by an event?
by prompt i mean the dev product purchase prompt
ohh i sorry im too tired today
ok so whats the final answer???
show your script then i will try to help, helped a few people today and feel like a hero.
– 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
you can show the prompt to buy a gamepass , developer product and subscription from any script
what is exactly not working in your script ?
ok ill show you, words words words
when i click:
nothing appears.
error:
dev_products_money2 is the script i sent before (server script)
just prompt the purchase from the local script directly
but then idk how to reward cash correctly after purchasing
and i also dont know what to put in local one
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
call PromptProductPurchase
directly
cool text because of the characters limit
can you please do the script for me plsssssssssssssssssssssssssssssss
workspace.GAMEPASSES1.SurfaceGui.shop.zFrame.g10k.image.a4.MouseButton1Click:Connect(function()
MarketPlaceService:PromptProductPurchase(Player , Yourproduct id)
end)
this should prompt the player to buy the developer product
k thanks really much but, now how can the server script work?