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

(UNSOLVED) Help With Making My Gamepass Purchase Script Work Without Having To Rejoin Game?

I Am Making A Gamepass Script and I Am Trying To Make It So The Players Get The Gamepass Item Without Rejoining The Game Here Is The Script: This Is All In A Server Script btw

local event = game.ReplicatedStorage.RemoteEvents.GamePPP
local gamepassid = 50179266
local last = game.ReplicatedStorage.RemoteEvents.Last
local part = game.Workspace.VIPRoomPurchase
local mps = game:GetService('MarketplaceService')




local function workpls(player, gamepassid, wasPurchased)
	local plr = game.Players:GetPlayerFromCharacter(player.Parent)
	if plr then
		if mps:UserOwnsGamePassAsync(plr.UserId, 50179266) then
			print('User Already Owns Gamepass!')
		else
		game:GetService('MarketplaceService'):PromptGamePassPurchase(plr,50179266)
			print('User Prompted To Purchase')
				if mps.PromptGamePassPurchaseFinished and wasPurchased == true then
				print('Working') -- For Testing
			end
		end
	end
end

part.Touched:Connect(workpls)

1 answer

✓ Accepted answer

I have tried this in studio and it seems to work

local MarketplaceService = game:GetService("MarketplaceService")

local gamePassId = 000000 --Your GamepassID

MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, purchasePassID, purchaseSuccess)
	if purchaseSuccess == true and purchasePassID == gamePassId then
		print(player.Name.." Bought the Gamepass")
	end
end)

keep in mind that that this script should be in SSS (ServerScriptService) to work

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