When working with the premium purchase modal in a module script, I noticed that the player variable returned by PromptPremiumPurchaseFinished() is nil. I just implemented this, so I do not know how long this issue has been present outside of my scenario. This is incredbily frustrating as I rely on it to determine if a user is immediately given an item or not in a shop dialog.
Code:
local MarketplaceService = game:GetService("MarketplaceService")
local PremiumPromptQueue = {}
local GamepassPromptQueue = {}
MarketplaceService.PromptPremiumPurchaseFinished:Connect(function(player)
print(player) -- Prints Nil
print(player.Name) -- Errors
table.insert(PremiumPromptQueue, player.Name) -- Also would Error
end)
MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player)
table.insert(GamepassPromptQueue, player.Name)
end)
local PurchaseYield = {}
PurchaseYield.WaitForPremiumResponse = function(plr)
if plr.MembershipType == Enum.MembershipType.Premium then return true end
local plrname = plr.Name
MarketplaceService:PromptPremiumPurchase(plr)
repeat wait(1) until table.find(PremiumPromptQueue, plrname) or plr == nil
if plr then
table.remove(table.find(PremiumPromptQueue, plrname))
if plr.MembershipType == Enum.MembershipType.Premium then
return true
end
else
table.remove(table.find(GamepassPromptQueue, plrname))
end
return false
end
return PurchaseYield