local Replicated = game:GetService("ReplicatedStorage")
local players = game:GetService("Players")
local ProductID = 1190752185 --Type DEV id here
local function processReceipt(receiptInfo)
local player = players:GetPlayerByUserId(receiptInfo.PlayerId)
if not player then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
Replicated.HINTS.Level1:FireClient(game:GetService("Players"))
end
MarketPlaceService.ProcessReceipt = processReceipt```
local Replicated = game:GetService("ReplicatedStorage")
local players = game:GetService("Players")
local ProductID = 1190752185 --Type DEV id here
local function ProductPurchase(player, assetId, isPurchased)
if assetId == ProductID then
if isPurchased == true then
print("Purchased")
-- Your script goes here
end
end
end
MarketplaceService.PromptPurchaseFinished:Connect(ProductPurchase)
You can use a BindableEvent | Roblox Creator Documentation for this. I do not recommend doing this client side because it will not be secure and will be vulnerable to exploiters.
Why do you have a service in the first parameter? You mean a player?
My bad, create a MarketplaceService variable by doing local MarketplaceService = game:GetService("MarketplaceService"). You can place at the start of the script.
Yes you can do with it. And I have a better script here.
local MarketplaceService = game:GetService("MarketplaceService")
local Replicated = game:GetService("ReplicatedStorage")
local players = game:GetService("Players")
local ProductID = 1190752185 --Type DEV id here
local function ProductPurchase(userId, assetId, isPurchased)
if assetId == ProductID then
if isPurchased == true then
print("Player "..userId.." purchased a product which has id "..assetId)
-- Your script goes here
end
end
end
MarketplaceService.PromptProductPurchaseFinished:Connect(ProductPurchase)
So I just done a research, PromptProductPurchaseFinished would be better.
If you want to use with TextButton, create a LocalScript inside the button you want to use. Then use this script.
local MarketplaceService = game:GetService("MarketplaceService")
local Replicated = game:GetService("ReplicatedStorage")
local players = game:GetService("Players")
local player = game.Players.LocalPlayer
local button = script.Parent
local ProductID = 1190752185 --Type DEV id here
local function ProductPurchase(userId, assetId, isPurchased)
if assetId == ProductID then
if isPurchased == true then
print("Player "..userId.." purchased a product which has id "..assetId)
-- Your script goes here
end
end
end
local function PromptProduct()
MarketplaceService:PromptProductPurchase(player, ProductID)
end
MarketplaceService.PromptProductPurchaseFinished:Connect(ProductPurchase)
button.MouseButton1Click:Connect(PromptProduct)
local Replicated = game:GetService("ReplicatedStorage")
local players = game:GetService("Players")
local player = game.Players.LocalPlayer
local button = script.Parent
local ProductID = 1190752185 --Type DEV id here
local function ProductPurchase(userId, assetId, isPurchased)
if assetId == ProductID then
if isPurchased == true then
print("Player "..userId.." purchased a product which has id "..assetId)
game.ReplicatedStorage.HINTS.Level1:FireClient()
end
end
end
local function PromptProduct()
MarketplaceService:PromptProductPurchase(player, ProductID)
end
MarketplaceService.PromptProductPurchaseFinished:Connect(ProductPurchase)
button.MouseButton1Click:Connect(PromptProduct)```