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

How do you make a script prompting more gamepasses?

The reason i'm making this is for future reference.

GOAL: I'm trying to make these parts prompt me when i step on them.

ERROR: It's not prompting me or saying that i already have the gamepass.

If you read these steps, it should be easy to answer my question

My script may be horribly formatted, but lets give it a try :)

ME: "Mom can we have a script at home"

MOM "We already have a script at home"

The Script:

local MarketPlaceService = game:GetService("MarketplaceService")
	local Players = game:GetService("Players")
	
	local HasPass = false
	 
	local PromptSpeed = game.Workspace:WaitForChild("PromptSpeed")
	local PromptBox = game.Workspace:WaitForChild("PromptPart")
	local PromptPower = game.Workspace:WaitForChild("PromptJump")
	local PromptVip = game.Workspace:WaitForChild("PromptVIP")
	 
	local function OnPromptPurchase(player, gamepassId)
	 
	    player = Players.LocalPlayer
	 
	local sucess, errormessage = pcall(function()
	    HasPass = MarketPlaceService:UserOwnsGamePassAsync(player.UserId, gamepassId)  


if HasPass then
	print("Player has gamepass")
	end


	if not HasPass then
		PromptSpeed.Touched:Connect(function()
			MarketPlaceService:PromptGamePassPurchase(OnPromptPurchase(player, 8638546))
			end)
				
				if not HasPass then
					PromptBox.Touched:Connect(function()
						MarketPlaceService:PromptGamePassPurchase(OnPromptPurchase(player, 8582273))
				end)
					
					if not HasPass then
						PromptPower.Touched:Connect(function()
							MarketPlaceService:PromptGamePassPurchase(OnPromptPurchase(player, 8796152))
					end)
						
						if not HasPass then
							PromptVip.Touched:Connect(function()
								MarketPlaceService:PromptGamePassPurchase(OnPromptPurchase(player, 8757181))
						end)
						end
						end
						end
						end
						end)
							end

Sorry for the joke in the beginning, it was just to keep you guys entertained :)

2 answers

✓ Accepted answer

Code below will promt the purchase id to player. Change the player to the player instance you want to prompt purchase of id, which could be e.g a gamepass.

game:GetService("MarketplaceService"):PromptPurchase(player, id)

2 comments

0

Yeah, that happens to me aswell bro. Good luck on your scripting career!!

0

ok!

Here's my finish result thanks to AspectW!

local MarketPlaceService = game:GetService("MarketplaceService")
	local Players = game:GetService("Players")
	
	local HasPass = false
	 
	local PromptSpeed = game.Workspace:WaitForChild("PromptSpeed")
	local PromptBox = game.Workspace:WaitForChild("PromptPart")
	local PromptPower = game.Workspace:WaitForChild("PromptJump")
	local PromptVip = game.Workspace:WaitForChild("PromptVIP")
	 
	local function OnPromptPurchase(player, gamepassId)
	 
	    player = Players.LocalPlayer
	 
	local sucess, errormessage = pcall(function()
	    HasPass = MarketPlaceService:UserOwnsGamePassAsync(player.UserId, gamepassId)  


if HasPass then return end


	if not HasPass then
		PromptSpeed.Touched:Connect(function(player)
			MarketPlaceService:PromptGamePassPurchase(player, 8638546)
			end)
				
				if not HasPass then
					PromptBox.Touched:Connect(function(player)
						MarketPlaceService:PromptGamePassPurchase(player, 8582273)
				end)
					
					if not HasPass then
						PromptPower.Touched:Connect(function(player)
							MarketPlaceService:PromptGamePassPurchase(player, 8796152)
					end)
						
						if not HasPass then
							PromptVip.Touched:Connect(function(player)
								MarketPlaceService:PromptGamePassPurchase(player, 8757181)
						end)
						end
						end
						end
						end
						end)
							end

4 comments

0

Wait... It does not work...

0

um...

0

NOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO

0

nevermind ;( i will never get the answer..

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