So I have this server code
game.ReplicatedStorage.PromptPurchase.OnServerEvent:Connect(function(Player, ID)
MarketplaceService:PromptPurchase(Player, ID)
MarketplaceService.PromptPurchaseFinished:Connect(function(player, assetId, bought)
if bought then
print(player.Name.." purchased "..assetId)
else
print(player.Name.." did not purchase "..assetId)
end
end)
end)
And this client code
Event = script.Parent.RemoteEvent
SGui = script.Parent
Whole = SGui["Whole frame"]
Top = Whole["top frame"]
Close = Top.close
TryP = Whole.TryOnPants
BuyP = Whole.BuyPants
TryS = Whole.TryOnShirt
BuyS = Whole.BuyShirt
local TryPClick
local BuyPClick
local TrySClick
local BuySClick
Event.OnClientEvent:Connect(function(p1, p2)
if p1 == "manneq" then
Tweens.GuiOpen:Play()
local Model = p2
local Shirt = Model:FindFirstChildOfClass("Shirt")
local Pants = Model:FindFirstChildOfClass("Pants")
if Shirt then
TryS.Visible = true
BuyS.Visible = true
local ID = Shirt.AssetId.Value
TrySClick = TryS.MouseButton1Click:Connect(function()
Event:FireServer("try", Shirt)
end)
BuySClick = BuyS.MouseButton1Click:Connect(function()
game.ReplicatedStorage.PromptPurchase:FireServer(ID)
end)
end
if Pants then
TryP.Visible = true
BuyP.Visible = true
local ID = Pants.AssetId.Value
TryPClick = TryP.MouseButton1Click:Connect(function()
Event:FireServer("try", Pants)
end)
BuyPClick = BuyP.MouseButton1Click:Connect(function()
game.ReplicatedStorage.PromptPurchase:FireServer(ID)
end)
end
end
end)
When I buy a shirt then the server prints out that I bought it. But when I go to buy a second item then the server prints two successful purchase messages and then prints out 3 when I buy the third item. Here is the output I get.
Barty200 purchased 6088610815 - Server
▼ Barty200 purchased 6044721418 (x2) - Server
Barty200 purchased 6044721418
▼ Barty200 purchased 5617933646 (x3) - Server
Barty200 purchased 5617933646
Barty200 purchased 5617933646
How do I fix this? Is this a problem with my code?