Hey how would I achieve something like this? (fx. like Pet Simulator did it)


How would I achieve smth like this where the background fades in when starting a purchase? Would I have to do this manually, or is there a method to check when a purchase starts?

Where you call MarketplaceService:PromptProductPurchase(), you can write code to show it. Then, use MarketplaceService.PromptProductPurchaseFinished to detect when the purchase is complete, and remove the gui.

2 Likes

Any way to do this without manually doing it everytime when prompting?

Tell me if I’m wrong but, you can use remote events, there’s a neat feature in the brackets. For example, the first word in the brackets after “function” will always call the player, no matter what. After you call the player you can put your variables that receive other variables. In my case, price & name are receiving something from the client and using it in the server. This is extremely useful for automation. It’s very simple to automate other things like this too. Don’t forget they need to be the exact same in the client, plr doesn’t need to be called from the client. The variables also need to exist within your client script (Outside of FireClient(price, name))

Thanks for your help, but i’m using MarketPlaceService so I can’t js use remoteevents.

I’ve made this to handle this

local MPS = {}

local function blur(player)
	if player and player:FindFirstChild("PlayerGui") then
		game:GetService("TweenService"):Create(player.PlayerGui:FindFirstChild("PurchaseProcessing").Frame, TweenInfo.new(.3), {BackgroundTransparency = .5}):Play()
		game:GetService("TweenService"):Create(game.Lighting:WaitForChild("PurchaseBlur"), TweenInfo.new(.3), {Size = 10}):Play()
	end
end

local function Stopblur(player)
	if player and player:FindFirstChild("PlayerGui") then
		game:GetService("TweenService"):Create(player.PlayerGui:FindFirstChild("PurchaseProcessing").Frame, TweenInfo.new(.3), {BackgroundTransparency = 1}):Play()
		game:GetService("TweenService"):Create(game.Lighting:WaitForChild("PurchaseBlur"), TweenInfo.new(.3), {Size = 0}):Play()
	end
end

function MPS:PromptProductPurchase(player:Player, id:number)
	blur(player)
	game:GetService("MarketplaceService"):PromptProductPurchase(player,id)
end

function MPS:PromptGamepassPurchase(player:Player, id:number)
	blur(player)
	game:GetService("MarketplaceService"):PromptGamePassPurchase(player,id)
end

function MPS:PromptPurchase(player:Player, id:number)
	blur(player)
	game:GetService("MarketplaceService"):PromptPurchase(player,id)
end

game:GetService("MarketplaceService").PromptGamePassPurchaseFinished:Connect(function(player)
	Stopblur(player)
end)

game:GetService("MarketplaceService").PromptPurchaseFinished:Connect(function(player)
	Stopblur(player)
end)

game:GetService("MarketplaceService").PromptProductPurchaseFinished:Connect(function(player)
	Stopblur(player)
end)

return MPS

You’ll have to do it manually every time, I’m afraid. Not for removing it, though; just make a connection, like you did in your example.


theres the results

3 Likes

Here’s how to make this

Your going to need a Gui, and a button that has “g_” before the actual pass name, within that button add a number value and put the gamepass id as the value. Tell me if this works, It worked for me.
Edit: Forgot, add a local script in the GUI and paste the contents below.

wait(game.Loaded)

local player = game:GetService(“Players”).LocalPlayer
local mps = game:GetService(“MarketplaceService”)
local gui = player.PlayerGui:FindFirstChild(“Game”)

for , child in ipairs(gui:GetChildren()) do
if child:IsA(“TextButton”) then
child.MouseButton1Click:Connect(function()
local childName = string.match(child.Name, "g
")
local childID = child:FindFirstChild(“ID”).Value
if childName then
print(childName) – you can delete this
mps:PromptGamePassPurchase(player, childID)
end
end)
end
end

If your looking for dev product purchase instead of “mps:PromptGamePassPurchase(player, childID)” use, “mps:PromptProductPurchase(player, childID)”

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