Only works for one player (PromptGamePassPurchase)

PopUp opens only for the last player who joined the game.
Thank you for your help!

local player = game.Players.LocalPlayer
local debounce = false
local mps = game:GetService("MarketplaceService")
EquipGui.EquipBoy.MouseButton1Click:connect(function()
	local NameTool = script.Parent.EquiparBoy.ItemName.Text
	local objectValue =  game.ReplicatedStorage.SavedTools:FindFirstChild(NameTool)
	local BackpackTool = player.Backpack:FindFirstChild(NameTool)
	if debounce == false then
		debounce = true
		if not BackpackTool then
				mps:PromptGamePassPurchase(player, objectValue.GamePass.Value)
				wait(0.5)
				debounce = false
			else
				script.Parent.Message.Visible = true
				wait(0.5)
				debounce = false
			end
		end
end)
1 Like

it would help if you provided more info like explorer or full script

I don’t think prompting purchase from LocalScripts are a good idea.

When I open the game with one account, the popup works normally, when I open the second account, the popup works and the popup of the first account stops working, it doesn’t open anymore

vid.wmv (850.1 KB)

local player = game.Players.LocalPlayer
local debounce = false
local mps = game:GetService("MarketplaceService")
EquipGui.EquipBoy.MouseButton1Click:connect(function()
	local NameTool = script.Parent.EquiparBoy.ItemName.Text
	local objectValue =  game.ReplicatedStorage.SavedTools:FindFirstChild(NameTool)
	local BackpackTool = player.Backpack:FindFirstChild(NameTool)
	if debounce == false then
		debounce = true
		if not BackpackTool then
				mps:PromptGamePassPurchase(player, objectValue.GamePass.Value)
				wait(0.5)
				debounce = false
			else
				script.Parent.Message.Visible = true
				wait(0.5)
				debounce = false
			end
		end
end)
mps.PromptGamePassPurchaseFinished:connect(function(player, id, purchased)
	local NameTool = script.Parent.EquiparBoy.ItemName.Text
		local objectValue =  game.ReplicatedStorage.SavedTools:FindFirstChild(NameTool)
		if id == objectValue.GamePass.Value and purchased then
			game.ReplicatedStorage.RemoteEvent.BackpackTool:FireServer(NameTool)
		end
end)
1 Like