Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

DevProducts are giving you what you've already bought?

Asked by 8 years ago
Edited 8 years ago

So, this script is rather messy but I'm just looking for one bug. This is for a dev product GUI. The GUI works well but every time you buy a new dev product, you get the new gear/money and also everything you had previously bought in the session. Help would be appreciated as well as any optimisation but i'm not to bothered about having it not lag as it is one of the only scripts in the game. I also understand there is probably a way to only use the purchases dictionary in one of the scripts but again, I have little interest in optimisation.

Global Handler: (Sorry for no indents!)

mp = game:GetService("MarketplaceService")
gui = script.Parent
purchaces = {["+health"] = 36743582, ["+speed"] = 36743578, ["10k"] = 36739107, ["20k"] = 36742505, ["30k"] = 36742526, ["40k"] = 36742576, ["50k"] = 36743511, ["5k"] = 36738719, Bomb = 36743569, Jetpack = 36743595, ["Laser Gun"] = 36743566, NUKE = 36743610, Rocket = 36743561} --REPLACE NUMBERS WITH GAMEPASS ID'S

mp.ProcessReceipt = function(receiptInfo)
reward = nil
for i,v in pairs(game.Players:GetChildren()) do
if v.userId == receiptInfo.PlayerId then
if Enum.ProductPurchaseDecision.PurchaseGranted then
local id = receiptInfo.ProductId
for i,v in pairs(purchaces) do
if v == id then
reward = i
end
end
if #reward == 3 then
local cash = string.sub(reward,1,2) .. "000"
v.leaderstats.Cash.Value = v.leaderstats.Cash.Value + tonumber(cash)    
elseif reward == "+health"  then
v.Character.Humanoid.MaxHealth = v.Character.Humanoid.MaxHealth + 10; v.Character.Humanoid.Health = v.Character.Humanoid.Health + 10
print(v.Character.Humanoid.Health)
elseif reward == "+speed" then
v.Character.Humanoid.WalkSpeed = v.Character.Humanoid.WalkSpeed + 10
elseif reward == "Bomb" then
game.ServerStorage.FuseBomb:Clone().Parent = v.Backpack
elseif reward == "Laser Gun" then
game.ServerStorage.hyper:Clone().Parent = v.Backpack
elseif reward == "Rocket" then
game.ServerStorage.RocketLauncher:Clone().Parent = v.Backpack
elseif reward == "Jetpack" then
game.ServerStorage.JetPack:Clone().Parent = v.Backpack
end
else
warn("ERROR - PURCHACE ABORTED OR FAILED")
end     
end
end
end

Local Handler:

gui = script.Parent
--PURCHACE HANDLER--
mp = game:GetService("MarketplaceService")
purchaces = {["+health"] = 36743582, ["+speed"] = 36743578, ["10k"] = 36739107, ["20k"] = 36742505, ["30k"] = 36742526, ["40k"] = 36742576, ["50k"] = 36743511, ["5k"] = 36738719, Bomb = 36743569, Jetpack = 36743595, ["Laser Gun"] = 36743566, NUKE = 36743610, Rocket = 36743561} --REPLACE NUMBERS WITH GAMEPASS ID'S

for i,v in pairs(purchaces) do
    gui[i].MouseButton1Down:connect(function()
            mp:PromptProductPurchase(game.Players.LocalPlayer, purchaces[gui[i].Name])
    end)
end

0
You need to add "return Enum.ProductPurchaseDecision.PurchaseGranted" to the end of the ProcessRecipt call back. M39a9am3R 3210 — 8y

Answer this question