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

(UNSOLVED) Help With Making My Gamepass Purchase Script Work Without Having To Rejoin Game?

Asked by 2 years ago
Edited 2 years ago

I Am Making A Gamepass Script and I Am Trying To Make It So The Players Get The Gamepass Item Without Rejoining The Game Here Is The Script: This Is All In A Server Script btw

local event = game.ReplicatedStorage.RemoteEvents.GamePPP
local gamepassid = 50179266
local last = game.ReplicatedStorage.RemoteEvents.Last
local part = game.Workspace.VIPRoomPurchase
local mps = game:GetService('MarketplaceService')




local function workpls(player, gamepassid, wasPurchased)
    local plr = game.Players:GetPlayerFromCharacter(player.Parent)
    if plr then
        if mps:UserOwnsGamePassAsync(plr.UserId, 50179266) then
            print('User Already Owns Gamepass!')
        else
        game:GetService('MarketplaceService'):PromptGamePassPurchase(plr,50179266)
            print('User Prompted To Purchase')
                if mps.PromptGamePassPurchaseFinished and wasPurchased == true then
                print('Working') -- For Testing
            end
        end
    end
end

part.Touched:Connect(workpls)

1 answer

Log in to vote
1
Answered by
VAnkata20 135
2 years ago
Edited 2 years ago

I have tried this in studio and it seems to work

local MarketplaceService = game:GetService("MarketplaceService")

local gamePassId = 000000 --Your GamepassID

MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, purchasePassID, purchaseSuccess)
    if purchaseSuccess == true and purchasePassID == gamePassId then
        print(player.Name.." Bought the Gamepass")
    end
end)

keep in mind that that this script should be in SSS (ServerScriptService) to work

Ad

Answer this question