OK So I a having trouble with a script. My problem is that that I have a script that handles Developer Tool Purchases. The first time someone purchases something it works fine, BUT if someone tries to purchase something ore than once it gives them the item 2 TIMES and charges them twice even though it should only charge them once. I know this ay sound confusing but I will try to clarify it.
If they buy $100 of in game currency the first time. Its gives the $100. If they try to buy it again it will give them $200 and charge them double the robux. If they try too purchase it 3 times it will give them $300 and triple the robux.
So The first time it gives them: $100 and charges them R$50, the second time it gives them $200 + the $100 from the original purchase and charges them R$100 plus the original R$50 they spent for the first purchase.
I cannot understand why it wouldn't just charge them for each purchase made and why it keeps progressing every time they push the button to purchase an item. Here is the script, please let me know if I did something wrong and also if there is a better way of going about this.
Here is the code for it:
local SaveToDataStore = game.ReplicatedStorage.SaveToDataStore local player = script.Parent.Parent.Parent.Parent local money = player.leaderstats.Money print(script.Parent.Parent.Parent.Parent) function getPlayerById(id) for i,v in pairs(game.Players:GetPlayers()) do if v.userId == id then return v end end end for _, button in pairs(script.Parent:GetChildren()) do if button:IsA("TextButton") then local productId = button.Value.Value local mps = game:GetService"MarketplaceService" local NumValue = button.NumValue.Value button.MouseButton1Click:connect(function() mps:PromptProductPurchase(script.Parent.Parent.Parent.Parent, productId) mps.ProcessReceipt = function(info) local plr = getPlayerById(info.PlayerId) if plr and plr:FindFirstChild"leaderstats" and plr.leaderstats:FindFirstChild"Money" then money.Value = money.Value + NumValue print ("Second Time It Processes" .. NumValue) SaveToDataStore:FireServer(money.Value) return end end end) end end
Well I figure it out and I am just keeping this up to let anyone else know who happens to run into this problem. I forgot to put
return Enum.ProductPurchaseDecision.PurchaseGranted
at the end of the script. Wow I feel dumb LOL