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

why is the gamepass not coming after you rejoin after buying?

Asked by 3 years ago
Edited 3 years ago

THIS SCRIPT IN STARTER PLAYER SCRIPTS local script

01local MarketPlaceService = game:GetService("MarketplaceService")
02 
03local gamePassID = 18759963
04 
05local function promptPurchase()
06 
07    local player = game.Players.LocalPlayer
08    local haspass = false
09 
10    local success, message = pcall(function()
11        haspass = MarketPlaceService:UserOwnsGamePassAsync(player.UserID, gamePassID)
12    end)
13 
14    if haspass == true then
15        print("Player Aldready has the gamepass")
View all 22 lines...

this in serverscriptservice

01local MarketPlaceService = game:GetService("MarketplaceService")
02local ReplicatedStorage = game:GetService("ReplicatedStorage")
03local sword = ReplicatedStorage:WaitForChild("ClassicSword")
04 
05local gamePassID = 18759963
06 
07MarketPlaceService.PromptGamePassPurchaseFinished:Connect(function(player, purchasePassID, purchaseSuccess)
08 
09    if purchaseSuccess == true and purchasePassID == gamePassID then
10        print(player.Name.. " purchased the sword gamepass")
11        sword.Parent = player.Character
12    end
13 
14end)

this also in server script service but in another script

01local MarketPlaceService = game:GetService("MarketplaceService")
02local ReplicatedStorage = game:GetService("ReplicatedStorage")
03local sword = ReplicatedStorage:WaitForChild("ClassicSword")
04 
05local gamePassID = 18759963
06 
07 
08game.Players.PlayerAdded:Connect(function(player)
09    wait(5)
10    local char = game.Workspace:FindFirstChild(player.Name)
11    local haspass = false
12 
13    local success, message = pcall(function()
14        haspass = MarketPlaceService:UserOwnsGamePassAsync(player.UserID, gamePassID)
15    end)
View all 21 lines...
0
did it work? Xyternal 247 — 3y
0
btw, get rid of that script in start player scripts. Its useless Xyternal 247 — 3y

1 answer

Log in to vote
0
Answered by
Xyternal 247 Moderation Voter
3 years ago

So you want to check if a player has a gamepass right? Well use this script. Everytime a player joins, it checks if the player has a gamepass.

01local id = YOUR_ID_HERE
02 
03game:GetService("MarketplaceService").PromptGamePassPurchaseFinished:Connect(function(plr,ido,purchased)
04    if purchased and ido == id then
05    -- your code when they have gamepass
06    end
07end)
08 
09game.Players.PlayerAdded:Connect(function(plr)
10    plr.CharacterAdded:connect(function(char)
11        if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(game.Players[char.Name].UserId, id) then
12            --copypaste the script you wrote earlier
13        end
14    end)
15end)

if it worked don't forget to accept it :P

Ad

Answer this question