How can I keep the same player from purchasing access when he joins?
I am making a testing place, and set it to BC only. One NBC complained that he wanted it to be free to play. So I looked through the free models to find a developer product base.(After making my product in my game.)And I found a script in the workspace with the localscript in starterpack. I have ran into a problem I can not seem to fix. If a player joins, he is not able to play(since a GUI covers his screen)the game until he buys the developer product for 5 robux. Once he buys it, the Gui vanishes and he is able to play. My problem is, if he rejoins again, he has to re-pay. I want it to be a 1 time payment. Here is the script in the Workspace:
01 | DataStore = game:GetService( "DataStoreService" ):GetDataStore( "PurchaseHistory" ) |
05 | game:GetService( "MarketplaceService" ).ProcessReceipt = function (infoo) |
06 | local playerDPkey = infoo.PlayerId.. ":" ..infoo.PurchaseId |
07 | if DataStore:GetAsync(playerDPkey) then |
10 | for i,v in pairs (game.Players:GetChildren()) do |
11 | if v.userId = = infoo.PlayerId then |
13 | if infoo.ProductId = = 22453272 then |
14 | if v.PlayerGui:FindFirstChild( "GameGui" ) then |
15 | v.PlayerGui.GameGui:Destroy() |
16 | elseif v.userId ~ = infoo.PlayerId then |
23 | DataStore:SetAsync(playerDPkey, true ) |
25 | return Enum.ProductPurchaseDecision.PurchaseGranted |
and here is the local script in the starterpack:
1 | local buyButton = game.Players.LocalPlayer.PlayerGui:WaitForChild( "GameGui" ).Frame.TextButton |
2 | local productId = 22453272 |
3 | buyButton.MouseButton 1 Click:connect( function () |
4 | game:GetService( "MarketplaceService" ):PromptProductPurchase(game.Players.LocalPlayer, productId) |
. Can anyone help me on figuring out how to do this?
Thanks for reading!
TroytheDestroyer