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

How do you make a script prompting more gamepasses?

Asked by 4 years ago

The reason i'm making this is for future reference.

GOAL: I'm trying to make these parts prompt me when i step on them.

ERROR: It's not prompting me or saying that i already have the gamepass.

If you read these steps, it should be easy to answer my question

My script may be horribly formatted, but lets give it a try :)

ME: "Mom can we have a script at home"

MOM "We already have a script at home"

The Script:

local MarketPlaceService = game:GetService("MarketplaceService")
    local Players = game:GetService("Players")

    local HasPass = false

    local PromptSpeed = game.Workspace:WaitForChild("PromptSpeed")
    local PromptBox = game.Workspace:WaitForChild("PromptPart")
    local PromptPower = game.Workspace:WaitForChild("PromptJump")
    local PromptVip = game.Workspace:WaitForChild("PromptVIP")

    local function OnPromptPurchase(player, gamepassId)

        player = Players.LocalPlayer

    local sucess, errormessage = pcall(function()
        HasPass = MarketPlaceService:UserOwnsGamePassAsync(player.UserId, gamepassId)  


if HasPass then
    print("Player has gamepass")
    end


    if not HasPass then
        PromptSpeed.Touched:Connect(function()
            MarketPlaceService:PromptGamePassPurchase(OnPromptPurchase(player, 8638546))
            end)

                if not HasPass then
                    PromptBox.Touched:Connect(function()
                        MarketPlaceService:PromptGamePassPurchase(OnPromptPurchase(player, 8582273))
                end)

                    if not HasPass then
                        PromptPower.Touched:Connect(function()
                            MarketPlaceService:PromptGamePassPurchase(OnPromptPurchase(player, 8796152))
                    end)

                        if not HasPass then
                            PromptVip.Touched:Connect(function()
                                MarketPlaceService:PromptGamePassPurchase(OnPromptPurchase(player, 8757181))
                        end)
                        end
                        end
                        end
                        end
                        end)
                            end

Sorry for the joke in the beginning, it was just to keep you guys entertained :)

2 answers

Log in to vote
1
Answered by
AspectW 431 Moderation Voter
4 years ago

Code below will promt the purchase id to player. Change the player to the player instance you want to prompt purchase of id, which could be e.g a gamepass.

game:GetService("MarketplaceService"):PromptPurchase(player, id)
0
Yeah, that happens to me aswell bro. Good luck on your scripting career!! AspectW 431 — 4y
0
ok! maxpax2009 340 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

Here's my finish result thanks to AspectW!

local MarketPlaceService = game:GetService("MarketplaceService")
    local Players = game:GetService("Players")

    local HasPass = false

    local PromptSpeed = game.Workspace:WaitForChild("PromptSpeed")
    local PromptBox = game.Workspace:WaitForChild("PromptPart")
    local PromptPower = game.Workspace:WaitForChild("PromptJump")
    local PromptVip = game.Workspace:WaitForChild("PromptVIP")

    local function OnPromptPurchase(player, gamepassId)

        player = Players.LocalPlayer

    local sucess, errormessage = pcall(function()
        HasPass = MarketPlaceService:UserOwnsGamePassAsync(player.UserId, gamepassId)  


if HasPass then return end


    if not HasPass then
        PromptSpeed.Touched:Connect(function(player)
            MarketPlaceService:PromptGamePassPurchase(player, 8638546)
            end)

                if not HasPass then
                    PromptBox.Touched:Connect(function(player)
                        MarketPlaceService:PromptGamePassPurchase(player, 8582273)
                end)

                    if not HasPass then
                        PromptPower.Touched:Connect(function(player)
                            MarketPlaceService:PromptGamePassPurchase(player, 8796152)
                    end)

                        if not HasPass then
                            PromptVip.Touched:Connect(function(player)
                                MarketPlaceService:PromptGamePassPurchase(player, 8757181)
                        end)
                        end
                        end
                        end
                        end
                        end)
                            end
0
Wait... It does not work... maxpax2009 340 — 4y
0
um... maxpax2009 340 — 4y
0
NOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO maxpax2009 340 — 4y
0
nevermind ;( i will never get the answer.. maxpax2009 340 — 4y

Answer this question