Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

I made a gamepass script in Roblox but it's not working?

So basically this is my script `` -- This code should be within a 'LocalScript' object local MarketplaceService = game:GetService("MarketplaceService") local Players = game:GetService("Players")

local gamePassID = 6738501 -- Change this to your game pass ID

-- Function to prompt purchase of the game pass local function promptPurchase()

local player = Players.LocalPlayer
local hasPass = false

local success, message = pcall(function()
	hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamePassID)
end)

if not success then
	warn("Error while checking if player has pass: " .. tostring(message))
	return
end

if hasPass == true then
	-- Player already owns the game pass; tell them somehow
else
	-- Player does NOT own the game pass; prompt them to purchase
	MarketplaceService:PromptGamePassPurchase(player, gamePassID)
end


-- This code should be within a 'LocalScript' object
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
 
local gamePassID = 6738501  -- Change this to your game pass ID
 
-- Function to prompt purchase of the game pass
local function promptPurchase()
 
	local player = Players.LocalPlayer
	local hasPass = false
 
	local success, message = pcall(function()
		hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamePassID)
	end)
 
	if not success then
		warn("Error while checking if player has pass: " .. tostring(message))
		return
	end
 
	if hasPass == true then
		-- Player already owns the game pass; tell them somehow
	else
		-- Player does NOT own the game pass; prompt them to purchase
		MarketplaceService:PromptGamePassPurchase(player, gamePassID)
	end

So can u help me

2 comments

0

in fact, you did not make this.

0

It doesn't matter did he make it himself or did he take it we are here to help him.

1 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.