Making a global announcement developer product, the first purchase works perfectly but the second time I buy it it does the announcement before even being purchased it just announces it in the second purchase of it, Any idea on how to fix that?
Script:
local RS = game:GetService("ReplicatedStorage")
local GA = RS.GlobalAnnouncement
local A = RS.Announcement
local MPS = game:GetService("MarketplaceService")
local Id = 1278759987
local function GAE()
GA.OnServerEvent:Connect(function(player, text)
script.Parent.Text = text
end)
end
MPS.ProcessReceipt = function(receiptinfo)
local player = game.Players:GetPlayerByUserId(receiptinfo.PlayerId)
if not player then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
if receiptinfo.ProductId == Id then
print(receiptinfo)
GAE()
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
Local Script:
local Announcement = game.StarterGui.Announcement.Announcement
local MPS = game:GetService("MarketplaceService")
local Id = 1278759987
--[[local function Opening()
Announcement:TweenPosition(
UDim2.new(0.281, 0, 0.037, 0),
"Out",
"Bounce",
0.5,
false
)
end
local function Closing()
Announcement:TweenPosition(
UDim2.new(-0.5, 0, 0.037, 0),
"Out",
"Bounce",
0.5,
false
)
end
]]
script.Parent.MouseButton1Up:Connect(function()
local textbox = script.Parent.Parent.TextBox.Text
GA:FireServer(textbox)
A:FireServer()
MPS:PromptProductPurchase(Player, Id)
end)