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
01 | local event = game.ReplicatedStorage.RemoteEvents.GamePPP |
02 | local gamepassid = 50179266 |
03 | local last = game.ReplicatedStorage.RemoteEvents.Last |
04 | local part = game.Workspace.VIPRoomPurchase |
05 | local mps = game:GetService( 'MarketplaceService' ) |
06 |
07 |
08 |
09 |
10 | local function workpls(player, gamepassid, wasPurchased) |
11 | local plr = game.Players:GetPlayerFromCharacter(player.Parent) |
12 | if plr then |
13 | if mps:UserOwnsGamePassAsync(plr.UserId, 50179266 ) then |
14 | print ( 'User Already Owns Gamepass!' ) |
15 | else |
I have tried this in studio and it seems to work
1 | local MarketplaceService = game:GetService( "MarketplaceService" ) |
2 |
3 | local gamePassId = 000000 --Your GamepassID |
4 |
5 | MarketplaceService.PromptGamePassPurchaseFinished:Connect( function (player, purchasePassID, purchaseSuccess) |
6 | if purchaseSuccess = = true and purchasePassID = = gamePassId then |
7 | print (player.Name.. " Bought the Gamepass" ) |
8 | end |
9 | end ) |
keep in mind that that this script should be in SSS (ServerScriptService) to work