How do I stop this from happening

I want to stop this so when you rejoin the game and you weren’t in the game for the entire time when you purchased an event, it won’t do it right when you join another server.


local MPS = game:GetService("MarketplaceService")

local function processReceipt(receiptInfo)
	local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
	if player then
		if receiptInfo.ProductId == (hidden) then
		elseif receiptInfo.ProductId == (hidden) then
		return Enum.ProductPurchaseDecision.PurchaseGranted

MPS.ProcessReceipt = processReceipt

How would I do this?

Maybe delete the waiting time? I’m not an expert programmer so that’s all I could think of. I could be completely wrong.

1 Like

No, I want to wait, I dont want an event to last like 00000000.1 milliseconds.

bump charschars

Sorry, not really understanding you very well. Forgive me if I’ve got this wrong but:

As far as I understand, you’ve got a developer product that triggers an in-game event. You want the player to be able to fully experience this event, and if they leave the game before they can, you want to repeat this event in another server.

Is this what you’re looking for? If not, sorry that I’m confused.

Yeah, but I don’t want to repeat the event.

Otherwise, it’ll bug my game out.

So what are you saying exactly? You want the player to buy the product once, and then have the event happen once?

Yes, and if you buy the event you can keep rejoining and rejoining, it would be like a gamepass instead of a dev product.

I don’t want this to happen.

I’m pretty sure that return Enum.ProductPurchaseDecision.PurchaseGranted has something to do with it.

If so, I want to return earlier on but that would give me an error.

Ok, let’s get this straight. You want a player to be able to buy a dev product, which will trigger a in-game event, which only happens once. Correct?

Yes, and it can’t happen again if you join a different server and you didn’t fully experience the event, because that’d be buggy.

(for example, you can only have 1 event running at a time and if you join a different server with this, this would bug out)

Gotcha. So with your current script, what are the wait() functions for?

The wait functions are to wait() until the event is done, otherwise the event would last like 0 milliseconds.

Why are you waiting until the event is done to grant purchase completed? (as far as I know), it just lets the player know the purchase went through successfully, in a way

I just said (otherwise the event would last like 0 milliseconds), sorry if I worded the original post wrong, I mean’t to give the event some time to process, for example the stuff would happen and it would wait like 200 seconds and then it would finish, because you need time to experience it.

I’m not sure if that’s the best idea, you should return the PurchaseGranted enum after they’ve purchased it in order to avoid other bugs. You can trigger the event (simultaneously) and return the enum.

I can’t because if I return it earlier on, it will give me an error.

What’s the error? Could you send the exact text or a screenshot?



That’s a different error. You can’t put code under the return function. If you want the event to run after the purchase, you can look into threading with the task.spawn function or coroutines

1 Like