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

GUI Removal when Dev Product purchased?

Asked by
Uroxus 350 Moderation Voter
10 years ago

In my game I have a GUI instead of using the paid access in the games access settings, because it makes access cheaper...

I've got 2 buttons, 1 for tix and 1 for robux, and Im trying to make it so when they buy one of the two Dev Products the GUI gets removed and they can see. (The GUI takes up all of the screen)

INFO: My GUI is like this: ScreenGui(named Entry) in starter GUI. And inside this I have my 2 buttons named Purchase with a local script in... The transactions work, I've tested it on an alt, its just the GUI dosent get removed... Heres my script:

local developerProduct = 22199999  -- Product id


game:GetService("MarketplaceService").ProcessReceipt = function(receipt)
    if receipt.ProductId == developerProduct then 
        for i,v in pairs(game.Players:GetPlayers()) do 
            if v.userId == receipt.PlayerId then
                    v.game.StarterGui.Entry.Background.Visible = false
                end
            end
        end
    end



Ps: I know Dev Products are a one time thing.... I also got some of this code from other questions, I've just modified it a little to suit what I need it for.

I have 2 of these scrips, one for each button, and they're both in ServerScriptService

1 answer

Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
10 years ago

Your problem is that you're attempting to index the Gui by;

v.game.StarterGui.Entry

if v is the player, does it make much sense that the game would be inside the player? When a player joins, everytime their character loads the guis from StarterGui get Cloned into their PlayerGui. You can access your entry gui in the player's PlayerGui;

v.PlayerGui.Entry

Also, make sure you're returning that the purchase has been granted. You can do this by returning 'Enum.ProductPurchaseDecision.PurchaseGranted'. If you neglect to do this you will not earn any money from the developer product.

So, to fix your script;

local developerProduct = 22199999


game:GetService("MarketplaceService").ProcessReceipt = function(receipt)
    if receipt.ProductId == developerProduct then 
        for i,v in pairs(game.Players:GetPlayers()) do 
            if v.userId == receipt.PlayerId then
                v.PlayerGui.Entry.Background.Visible = false
            end
        end
    end
    return Enum.ProductPurchaseDecision.PurchaseGranted
end
1
Haha noob scripter errors =D Cheers man Uroxus 350 — 10y
0
One question. Is it possible to somehow have a list of players that this GUI dosent come up for?? I'm trying to test things but dont want to pay to see what Im doing in my own game, But if people follow me they will see whats behind the GUI for free .. Uroxus 350 — 10y
0
You mean like next time they join to not have to prompt them with this again? You'd have to use datastores to log the players that have bought the Developer Product. You can PM me about this if you want, I love DataStores(: Goulstem 8144 — 10y
Ad

Answer this question