Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I keep the same player from purchasing access when he joins?

Asked by 9 years ago

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:

DataStore = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")



game:GetService("MarketplaceService").ProcessReceipt = function(infoo)
    local playerDPkey = infoo.PlayerId..":"..infoo.PurchaseId
    if DataStore:GetAsync(playerDPkey) then
    else
        print(playerDPkey)
        for i,v in pairs(game.Players:GetChildren()) do
            if v.userId == infoo.PlayerId then

                if infoo.ProductId == 22453272 then
                    if v.PlayerGui:FindFirstChild("GameGui") then
                    v.PlayerGui.GameGui:Destroy()
                    elseif v.userId ~= infoo.PlayerId then
                    v:Kick()
                    end
                end

            end
        end
        DataStore:SetAsync(playerDPkey, true)
    end
    return Enum.ProductPurchaseDecision.PurchaseGranted
end

and here is the local script in the starterpack:


local buyButton = game.Players.LocalPlayer.PlayerGui:WaitForChild("GameGui").Frame.TextButton local productId = 22453272 buyButton.MouseButton1Click:connect(function() game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer, productId) end)

. Can anyone help me on figuring out how to do this? Thanks for reading! TroytheDestroyer

1 answer

Log in to vote
0
Answered by
iLegitus 130
9 years ago

Eh,Your problem is the DevProduct itself, Developer Products are not suited for this. Try gamepasses. Difference : Gamepasses : Save purchase,(1 purchase time only) DevProdcuts : Non-Saving Purchase (Multiple time purchase)

0
Then again,Paid acess suits it aswell (But minimum is 25R$) iLegitus 130 — 9y
0
I know, but if you go to roblox code school and teleport to the asylum, it prompts you to buy a product to access the game. After you buy it, you can rejoin and still have access. TroytheDestroyer 75 — 9y
0
Well,Thats still the same,Either its a t-shirt or a gamepass. (Just not implemented in a game). iLegitus 130 — 9y
Ad

Answer this question