[SOLVED] Gui won't appear after buying a dev product

  1. What do you want to achieve? I want the GUI to appear 30 seconds after the developer product was bought. It should always do this.

  2. What is the issue? The GUI doesnt appear after buying a developer product about 1-3 times then it will never appear again in a single session.

  3. What solutions have you tried so far? I looked on devforums, I found nothing. I also checked my folders in my explorer and haven’t found anything that could be making this issue. I even tried with AI.

Ask questions if you need more information.

local button = script.Parent
local replicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = replicatedStorage:WaitForChild("RemoteEvent")
local productidd = 1839490031
button.Visible = false
local function handleButtonVisibility()
	while true do
		local duplicants = game.Workspace.duplicants:GetChildren()
		local foundPart = false
		for _, child in ipairs(duplicants) do
			if child.Name == "Part" then
				foundPart = true
				break
			end
		end
		if foundPart then
			task.wait(8)
			button.Visible = true
			break
		end
		wait(0.1)
	end
end
handleButtonVisibility()
button.MouseButton1Click:Connect(function()
	button.Visible = false
	game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer, productidd)
end)
game:GetService("MarketplaceService").PromptProductPurchaseFinished:Connect(function(player, produid, waspurch)
	if produid == productidd then
		if waspurch then
			remoteEvent:FireServer()
		else
			button.Visible = true
		end
	end
end)
task.wait(30)
button.Visible = true

After the developer product gets bought it will make the GUI reappear 30 seconds after.

Can we see the code that receives the OnServerEvent?

There’s also quite a few things wrong with this; for starters you are using PromptProductPurchaseFinished (which should not be used for product processing) and you are doing it on the client and connecting it to a remote. This makes it extremely vulnerable to exploiters. Instead, you should use MarketplaceService.ProcessReceipt on the server to handle all dev product purchases.

Sure, I’ll apply some changes and I will also send the script here! I have also applied the changes to the local script for purchasing.
image

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")
local explodeconnector = Instance.new("Part")

explodeconnector.Size = Vector3.new(5, 5, 5)
explodeconnector.Position = Vector3.new(0, 50, 0)
explodeconnector.Anchored = true
explodeconnector.Transparency = 1
explodeconnector.CanCollide = false
explodeconnector.Name = "explodepart"
explodeconnector.Parent = game.Workspace
RemoteEvent.OnServerEvent:Connect(function(player)
	local function explosion()
		local explode = Instance.new("Explosion")
		explode.ExplosionType = Enum.ExplosionType.NoCraters
		explode.Position = explodeconnector.Position
		explode.BlastRadius = 350
		explode.BlastPressure = 75000000
		explode.DestroyJointRadiusPercent = 0
		explode.Parent = game.Workspace
		game.Workspace.Gravity = 0
		task.wait(0.5)
		game.Workspace.Gravity = 196.2
		explode:Destroy()
	end
	explosion()
	task.wait(0.1)
	explosion()
	task.wait(0.1)
	explosion()
	task.wait(0.1)
	explosion()
	task.wait(0.1)
	explosion()
	task.wait(0.5)
	game.Workspace.Gravity = 196.2
end)

I’m new at this I probably got it wrong but this was the error I got with “processreceipt”

20:48:14.819 ProcessReceipt is a callback member of MarketplaceService; you can only set the callback value, get is not available - Client - LocalScript:29

no, you do it in the server. I’d recommend taking a look at the documentation.

Sorry, but I don’t understand.

I have looked at it about 5 times already and I still don’t get it.,

still have the issue :((
I can’t figure this out

Hmm…
Is it because the line

task.wait(30)
button.Visible = true

Isn’t inside the function handleButtonVisibility()? Or maybe it should be in another function, because it seems that it’s just at the end of the code.

Do you know how i could implemant “ProcessReceipt”?

Not quite sure how to do that…

About the end of the code thing, it’s because it should appear after it gets bought not after it detected parts

Considering that it’s not in a function, the button.Visible = true line would only run once. Maybe this is the issue. Try placing

task.wait(30)
button.Visible = true

Inside of the function that hides it after it gets bought, if applicable

Well i would have to fire another event after which might result into an infinite yield but ill try.

1 Like

I currently am trying to fix another issue im experiencing.

1 Like

It’s alright, take your time :+1:

Got an issue with this script, when I buy the dev product I get no signs of an infinite yield or errors but it never prints.

button.MouseButton1Click:Connect(function()
	button.Visible = false
	game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer, productidd)
end)

game:GetService("MarketplaceService").PromptPurchaseFinished:Connect(function(player, produid, waspurch)
	if produid == productidd then
		if waspurch then
			print("event fired") -- Wont trigger print, expected invisible infinite yield.
			re:FireServer()
		else
			print("event fail") -- Wont trigger print, expected invisible infinite yield.
			button.Visible = true
		end
	end
end)

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MarketplaceService = game:GetService("MarketplaceService")

local button = script.Parent
local duplicants = workspace:WaitForChild("duplicants")
local remoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")

button.Visible = false

duplicants.ChildAdded:Connect(function(part)
	if part:IsA("Part") then
		task.wait(8)
		button.Visible = true
	end
end)

button.MouseButton1Click:Connect(function()
	local productId = 1839490031
	MarketplaceService:PromptProductPurchase(Players.LocalPlayer, productId)
	
	button.Visible = false
end)

MarketplaceService.PromptProductPurchaseFinished:Connect(function(userId, productId, isPurchased)
	if isPurchased then
		remoteEvent:FireServer()
		
		-- after it was purchased, the button will reappear after 30 seconds.
		task.wait(30)
		button.Visible = true
	else
		button.Visible = true
	end
end)

I’ll review this, thank you so much! You didn’t have to redesign all this though. But still thanks!

1 Like