So I have this script where the player purchases the DevProduct and receives the cash amount, it works the first time, but then it starts to times itself by two? Any Fixes!?
DevproductHandler
local Settings = require(script.Parent.Settings)
local Tycoon = script.Parent.Tycoons:GetChildren()[1]
script.Parent = game.ServerScriptService
local DevProducts = {}
local DevProductModule = require(game.ReplicatedStorage.Modules.DevProductPrices)
local MarketplaceService = game:GetService('MarketplaceService')
for i,v in pairs(Tycoon:WaitForChild('Buttons'):GetChildren()) do
if v:FindFirstChild('DevProduct') then
if v.DevProduct.Value > 0 then
DevProducts[v.DevProduct.Value] = v -- the button
end
end
end
function getPlayerFromId(id)
for i,v in pairs(game.Players:GetChildren()) do
if v.userId == id then
return v
end
end
return nil
end
MarketplaceService.ProcessReceipt = function(receiptInfo)
local productId = receiptInfo.ProductId
local playerId = receiptInfo.PlayerId
local player = getPlayerFromId(playerId)
local productName
if productId == DevProductModule.Cash1.DevProductID then
local cashmoney = game.ServerStorage.PlayerMoney:FindFirstChild(player.Name)
if cashmoney then
cashmoney.Value = cashmoney.Value + DevProductModule.Cash1.Amount
warn("Just Bought + 1000 Cash")
warn(DevProductModule.Cash1.Amount)
end
elseif productId == 980001242 then
game.ReplicatedStorage.Quest.SkipQuest:FireClient(player,'Quest')
-------------------------------------------------------------------
return Enum.ProductPurchaseDecision.PurchaseGranted
end
for i,plr in pairs(game.Players:GetPlayers()) do
if plr.userId == receiptInfo.PlayerId then
if DevProducts[receiptInfo.ProductId] then
local obj = DevProducts[receiptInfo.ProductId]
local PlrT = game.ServerStorage.PlayerMoney:WaitForChild(plr.Name).OwnsTycoon
if PlrT.Value ~= nil then
--if PlrT.Value.PurchasedObjects:FindFirstChild(obj.Object.Value) == false then
local PlayerStats = game.ServerStorage.PlayerMoney:FindFirstChild(plr.Name)
Create({[1] = 0,[2] = obj,[3] = PlayerStats}, PlrT.Value.BuyObject)
--end
end
end
end
end
end
function Create(tab, prnt)
local x = Instance.new('Model')
Instance.new('NumberValue',x).Value = tab[1]
x.Value.Name = "Cost"
Instance.new('ObjectValue',x).Value = tab[2]
x.Value.Name = "Button"
local Obj = Instance.new('ObjectValue',x)
Obj.Name = "Stats"
Obj.Value = tab[3]
x.Parent = prnt
end
Module
local DevProducts = {
Cash1 ={
Onsale = true,
Name = "1000 Cash",
Amount = 1000,
RobuxPrice = 25, -- No Real Purpose, Just To See Price :-o
PurchasePromp = "Buy [????25]",
DevProductID = 980466182,
Image = "rbxassetid://431283974",
}
}
return DevProducts

1 comment
help