Hello, I made a script that gives coins or a potion when the developer product is purchased, the coins were working earlier but after i updated the script nothing is working!
Here is the script:
--service variables
local MPS = game:GetService("MarketplaceService")
local SS = game:GetService("ServerStorage")
local players = game:GetService("Players")
--items
local speed_potion = SS:WaitForChild("Potions"):WaitForChild("Speed_Potion")
local inv_potion = SS:WaitForChild("Potions"):WaitForChild("Invincibility_Potion")
local jump_potion = SS:WaitForChild("Potions"):WaitForChild("Jump_Potion")
local coin_potion = SS:WaitForChild("Potions"):WaitForChild("Coin_Potion")
--potion ids
local SP = 1260377051
local IP = 1260377099
local JP = 1260377073
local CP = 1260377128
-- coin ids
local five = 1260385747
local ten = 1260377270
local fifty = 1260385795
local hundred = 1260377308
local HundredFifty = 1260377249
local twoHundred = 1260385599
local twoHunderFifty = 1260385672
local FiveHundred = 1260385845
local OneK = 1260377333
--function
local function processReciept (recieptInfo)
local player = players:GetPlayerByUserId(recieptInfo.PlayerId)
if not player then
-- The player probably left the game
-- If they come back, the callback will be called again
return Enum.ProductPurchaseDecision.NotProcessedYet
end
--potions
if recieptInfo.ProductId == SP then
if player then
--product use
local char = game.Workspace:FindFirstChild(player.Name)
local SPClone = speed_potion:Clone()
SPClone.Name = "Speed Potion"
SPClone.Parent = char.Backpack
SPClone.Parent = char.StarterGear
print(player.Name.." just bought "..recieptInfo.ProductId)
end
end
if recieptInfo.ProductId == IP then
if player then
--product use
local char = game.Workspace:FindFirstChild(player.Name)
local IPClone = inv_potion:Clone()
IPClone.Name = "Invincibility Potion"
IPClone.Parent = char.Backpack
IPClone.Parent = char.StarterGear
print(player.Name.." just bought "..recieptInfo.ProductId)
end
end
if recieptInfo.ProductId == JP then
if player then
--product use
local char = game.Workspace:FindFirstChild(player.Name)
local JPClone = jump_potion:Clone()
JPClone.Name = "Jump Potion"
JPClone.Parent = char.Backpack
JPClone.Parent = char.StarterGear
print(player.Name.." just bought "..recieptInfo.ProductId)
end
end
if recieptInfo.ProductId == CP then
if player then
--product use
local char = game.Workspace:FindFirstChild(player.Name)
local CPClone = coin_potion:Clone()
CPClone.Name = "Coin Potion"
CPClone.Parent = char.Backpack
CPClone.Parent = char.StarterGear
print(player.Name.." just bought "..recieptInfo.ProductId)
end
end
--coins
if recieptInfo.ProductId == five then
if player then
--product use
local stats = player:FindFirstChild("leaderstats")
local Coins = stats and stats:FindFirstChild("Coins")
Coins.Value = Coins.Value + 5
print(player.Name.." just bought "..recieptInfo.ProductId)
end
end
if recieptInfo.ProductId == ten then
if player then
--product use
local stats = player:FindFirstChild("leaderstats")
local Coins = stats and stats:FindFirstChild("Coins")
Coins.Value = Coins.Value + 10
print(player.Name.." just bought "..recieptInfo.ProductId)
end
end
if recieptInfo.ProductId == fifty then
if player then
--product use
local stats = player:FindFirstChild("leaderstats")
local Coins = stats and stats:FindFirstChild("Coins")
Coins.Value = Coins.Value + 50
print(player.Name.." just bought "..recieptInfo.ProductId)
end
end
if recieptInfo.ProductId == hundred then
if player then
--product use
local stats = player:FindFirstChild("leaderstats")
local Coins = stats and stats:FindFirstChild("Coins")
Coins.Value = Coins.Value + 100
print(player.Name.." just bought "..recieptInfo.ProductId)
end
end
if recieptInfo.ProductId == HundredFifty then
if player then
--product use
local stats = player:FindFirstChild("leaderstats")
local Coins = stats and stats:FindFirstChild("Coins")
Coins.Value = Coins.Value + 150
print(player.Name.." just bought "..recieptInfo.ProductId)
end
end
if recieptInfo.ProductId == twoHundred then
if player then
--product use
local stats = player:FindFirstChild("leaderstats")
local Coins = stats and stats:FindFirstChild("Coins")
Coins.Value = Coins.Value + 200
print(player.Name.." just bought "..recieptInfo.ProductId)
end
end
if recieptInfo.ProductId == twoHunderFifty then
if player then
--product use
local stats = player:FindFirstChild("leaderstats")
local Coins = stats and stats:FindFirstChild("Coins")
Coins.Value = Coins.Value + 250
print(player.Name.." just bought "..recieptInfo.ProductId)
end
end
if recieptInfo.ProductId == FiveHundred then
if player then
--product use
local stats = player:FindFirstChild("leaderstats")
local Coins = stats and stats:FindFirstChild("Coins")
Coins.Value = Coins.Value + 500
print(player.Name.." just bought "..recieptInfo.ProductId)
end
end
if recieptInfo.ProductId == OneK then
if player then
--product use
local stats = player:FindFirstChild("leaderstats")
local Coins = stats and stats:FindFirstChild("Coins")
Coins.Value = Coins.Value + 1000
print(player.Name.." just bought "..recieptInfo.ProductId)
end
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
MPS.ProcessReceipt = processReciept