So, I Have two problems the first one is that when the player buys the developer product the event fires 2,3 or 4 times for some reason. The second problem is that after the part “PromptProductPurchaseFinished”, the player variable turns into the userId, but I need the player.
Could someone help me?
local MarketplaceService = game:GetService("MarketplaceService")
local serverScriptService = game:GetService("ServerScriptService")
local inLine = script.Parent:WaitForChild("InLine")
local clickDetector = script.Parent
local gamepassID = 1893240069
local waitTime = serverScriptService.BallScript.WaitTime
local players = {}
wait(waitTime.Value + 1)
clickDetector.MouseClick:connect(function(player)
MarketplaceService:PromptProductPurchase(player, gamepassID)
MarketplaceService.PromptProductPurchaseFinished:Connect(function(player, gamepassID, purchased)
if purchased then
if not player[player.Name] then -- I know I could use table.find, but that dind't work because of the userId
table.insert(players,player.Name)
inLine.Value += 1
else
wait(1)
table.remove(players,player.Name)
end
end
end)
end)