I need my script to not double the transaction every-time the event fires to give the player money.
Everytime the player buys a developer product or earns cash, it doubles after the second time they use the remote and it goes off from there.
I have looked at the server script and it seems even adding debounce wont work, and checking to see if the client sends double the amount, but I only included the amount in the server yet it still doubles the amount everytime.
I’ve tried every solution and I’m stuck at why the script is attempting to store the value after it has been given to the player. So in my mind it’s doing it right the first time. but after it’s done the first time, it stored the amount for the next purchase, so it adds it to there.
When watching the Gif, look at the output and look how it doubles the end.
Are there currently any errors you could provide? It would be helpful if you could list errors, and screen shot them, also, before posting, making sure to debug is always a good path. Adding print() statements around your code will show what works, and if one of them does not print when it needs to, you then know where the code is messing up!
It should only be like this.
Player press button: Player buys developer product: Player receives exact amount:done>
What my script does:
Player presses button: Player Buys developer product: Player receives twice as much as before.
Once the server is fired, fire the server with gamepassname, and gamepassiD
Do this;
local MPS = game:GetService("MarketplaceService")
MPS:PromptProductPurchase(player,id) --Prompt it server side, when they click only fire
MPS.ProcessReceipt = function(Recipt)
if Enum.ProductPurchaseDecision.PurchaseGranted and Recipt.PlayerId == player.userId then
--give them the goods
The first thing you need to do is remove that debounce. Having a global debounce like that will cause players to not be able to purchase if two players try to purchase something at the same time. The second thing is you can’t add Enum.ProductPurcahseDecision.NotProcessedYet in a if then statement. You have to return that at the end of the function. That’s why it’s doubling. I used to have this issue when I first started programming.
if Enum.ProductPurchaseDecision.PurchaseGranted then
This doesn’t work!! You have to return this at the end of your ProcessReceipt function. You can’t check an Enum as Enums never change! This is what happens when you print the Enum. There’s no true false.
Alright, thanks for letting me know I guess. If you noticed, it also Processes the receipt, and checks if the UserId is the same in the receipt, I am pretty sure if we remove the Enum the code would still work how it should. But I didn’t know that it doesn’t return true or false, thanks.