THIS SCRIPT IN STARTER PLAYER SCRIPTS local script
local MarketPlaceService = game:GetService("MarketplaceService") local gamePassID = 18759963 local function promptPurchase() local player = game.Players.LocalPlayer local haspass = false local success, message = pcall(function() haspass = MarketPlaceService:UserOwnsGamePassAsync(player.UserID, gamePassID) end) if haspass == true then print("Player Aldready has the gamepass") else MarketPlaceService:PromptGamePassPurchase(player, gamePassID) end end wait(5) promptPurchase()
this in serverscriptservice
local MarketPlaceService = game:GetService("MarketplaceService") local ReplicatedStorage = game:GetService("ReplicatedStorage") local sword = ReplicatedStorage:WaitForChild("ClassicSword") local gamePassID = 18759963 MarketPlaceService.PromptGamePassPurchaseFinished:Connect(function(player, purchasePassID, purchaseSuccess) if purchaseSuccess == true and purchasePassID == gamePassID then print(player.Name.. " purchased the sword gamepass") sword.Parent = player.Character end end)
this also in server script service but in another script
local MarketPlaceService = game:GetService("MarketplaceService") local ReplicatedStorage = game:GetService("ReplicatedStorage") local sword = ReplicatedStorage:WaitForChild("ClassicSword") local gamePassID = 18759963 game.Players.PlayerAdded:Connect(function(player) wait(5) local char = game.Workspace:FindFirstChild(player.Name) local haspass = false local success, message = pcall(function() haspass = MarketPlaceService:UserOwnsGamePassAsync(player.UserID, gamePassID) end) if haspass == true then print("Player has sword gamepass") sword.Parent = char end end)
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.
local id = YOUR_ID_HERE game:GetService("MarketplaceService").PromptGamePassPurchaseFinished:Connect(function(plr,ido,purchased) if purchased and ido == id then -- your code when they have gamepass end end) game.Players.PlayerAdded:Connect(function(plr) plr.CharacterAdded:connect(function(char) if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(game.Players[char.Name].UserId, id) then --copypaste the script you wrote earlier end end) end)
if it worked don't forget to accept it :P