Prompt GamePass purchase doesn't work

Try this:

local mps = game:GetService("MarketplaceService")

script.Parent.MouseButton1Click:Connect(function()
	mps:PromptGamePassPurchase(game.Players.LocalPlayer, script.Parent:WaitForChild("GamepassID").Value) 
end)
1 Like

1 Like

Can you check name of instance?

1 Like

Where do i check that i am quiet new.

1 Like

do you have a gamepassID? if yes could you send it to us?

2 Likes

Check GamepassID name like if it is the same.

1 Like

Here you go thats my gamepass id 255612370

1 Like

Can you show us a screenshot of the Explorer window?

1 Like

Thanks @mpc19801981 you helped me it works :slight_smile:

1 Like

Thanks but do you know how to make the gamepass item work so when i buy it it gives me the item

1 Like

Are you sure it’s the original climb 1000 stairs?:face_with_raised_eyebrow:

1 Like

Umm ur right i should change it

1 Like

I made new Topic You can chek it out if you want to.

1 Like

I dont see ur messages just write on my new TOPIC

1 Like

Add this Tool to ReplicatedStorage
Then make Script in ServerScriptService
And add this code into this script:

local rs =  game:GetService("ReplicatedStorage")
local mps = game:GetService("MarketplaceService")
local plrs = game:GetService("Players")
local Tool = rs:WaitForChild("PutHereToolName")
local gamePassId = 255612370
local function AddTool(player)
       if mps:UserOwnsGamePassAsync(player.UserId,gamePassId) then
             local Clone = tool:Clone() 
             Clone.Parent = player:WaitForChild("Backpack")
         end 
end
plrs.PlayerAdded:Connect(AddTool)
mps.PromptGamePassPurchaseFinished:Connect(AddTool)
1 Like

Check if player has the game pass using MarketplaceService:UserOwnsGamePassAsync() and detecting when the player bought the game pass in-game using MarketplaceService.PromptGamePassPurchaseFinished.

Then, give the player the rainbow carpet using InsertService:LoadAsset() and gear id of rainbow carpet which is 225921000.

-- place this script in ServierScriptService, must be a normal script
local Players = game:GetService("Players")
local Debris = game:GetService("Debris") -- used for deleting instances
local MarketplaceService = game:GetService("MarketplaceService")
local InsertService = game:GetService("InsertService")

local gamePassId = 255612370 -- rainbow carpet game pass
local gearId = 225921000 --  rainbow carpet gear

local function rewardPlayer(player: Player)
	local gearModel = InsertService:LoadAsset(gearId)
	local gear = gearModel:FindFirstChildWhichIsA("BackpackItem") -- gets the tool or hopperbin in gearModel
	
	gear:Clone().Parent = player:WaitForChild("Backpack")
	gear.Parent = player:WaitForChild("StarterGear")
	
	Debris:AddItem(gearModel, task.wait()) -- deletes gearModel
end

local function playerJoined(player: Player)
	if MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamePassId) then
		rewardPlayer(player)
	end
end

MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, id, success)
	if id == gamePassId and success == true then
		rewardPlayer(player)
	end
end)

for _, player in ipairs(Players:GetPlayers()) do
	task.spawn(playerJoined, player)
end

Players.PlayerAdded:Connect(playerJoined)
1 Like

post this on my other topic

so i can check as solution

1 Like

To check if player have gamepass:

local user_have_gamepass = game:GetService('MarketplaceService'):UserOwnsGamePassAsync(Player.UserId, Gamepass_ID) -- Cheking if player have item.

if user_have_gamepass then
    -- Give item
end

-- ^ This part of code can be used for client-side or server-side scripts. ^

-- Event that fired only when player prompted purchase:

game:GetService('MarketplaceService').PromptGamePassPurchaseFinished:Connect(function(Player, Gamepass_ID, Was_Purchased)
if Player and Gamepass_ID == *Id of gamepass* and Was_Purchased then
-- Give item to player.
end
end)

-- ^ This part of code can be used only for server-side scripts. ^

Oh, I guess I’m mistaken. When I learned to script it was always do it on the server for extra protection or something… idrk, anyway if it works on the client then that’s great!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.