What is meant to happen is if a player buys this Developer Product, a GUI appears that let's them select a team. The GUI then doesn't show up again until the player wants to Change team again.
The teams are Vigile and Police
What this script does though I believe is make the GUI appear every time the player plays the game, however, the Prompt for the Dev Product doesn't appear also.
Please can someone have a look?
wait() local buyButton = script.Parent productId = 21309094 -- when player clicks on buy brick promt him/her to buy a product buyButton.MouseButton1Click:connect(function() game:GetService("MarketplaceService"):PromptProductPurchase(script.Parent.Parent.Parent.Parent, productId) end) -- setup local variables local MarketplaceService = game:GetService("MarketplaceService") local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory") game.Players.PlayerAdded:connect(function() print("start") local DeveloperProducts = game:GetService("MarketplaceService"):GetDeveloperProductsAsync():GetCurrentPage() for _, DevProductContainer in pairs(DeveloperProducts) do for Field, Value in pairs(DevProductContainer) do print(Field .. ": " .. Value) end print(" ") end print("end") end) -- define function that will be called when purchase finished MarketplaceService.ProcessReceipt = function(receiptInfo) -- find the player based on the PlayerId in receiptInfo for i, player in ipairs(game.Players:GetChildren()) do if player.userId == receiptInfo.PlayerId then local plr = player -- check which product was purchased if receiptInfo.ProductId == productId then -- handle purchase. In this case we are healing the player. -- more feedback for the player. game.Lighting.Setup2:Clone().Parent = plr.PlayerGui end end end -- record the transaction in a Data Store local playerProductKey = "p_" .. receiptInfo.PlayerId .. "_p_" .. receiptInfo.PurchaseId ds:IncrementAsync(playerProductKey, 1) -- tell ROBLOX that we have successfully handled the transaction return Enum.ProductPurchaseDecision.PurchaseGranted end