Hi,
I wrote a script which would detect when player purchase a thing but events MarketplaceService.PromptGamePassPurchaseFinished and MarketplaceService.PromptPurchaseFinished are not working I checked by printing
Script in ServerScriptService
local MarketplaceService = game:GetService("MarketplaceService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ShowPurchaseCompletedScreen = ReplicatedStorage:WaitForChild('ShowPurchaseCompletedScreen')
MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player: Instance, assetId: number, isPurchased: boolean)
if isPurchased then
local ProductInfo = MarketplaceService:GetProductInfo()
if player:GetAttribute("RobuxSpent") then
player:SetAttribute("RobuxSpent", player:GetAttribute("RobuxSpent") + ProductInfo.PriceInRobux)
end
ShowPurchaseCompletedScreen:FireClient(player, assetId)
end
end)
MarketplaceService.PromptPurchaseFinished:Connect(function(player: Instance, assetId: number, isPurchased: boolean)
if isPurchased then
local ProductInfo = MarketplaceService:GetProductInfo()
if player:GetAttribute("RobuxSpent") then
player:SetAttribute("RobuxSpent", player:GetAttribute("RobuxSpent") + ProductInfo.PriceInRobux)
end
ShowPurchaseCompletedScreen:FireClient(player, assetId)
end
end)