For some reason, this script works in Studio, but there’s some infinite yield where it can’t return the requests correctly. I just don’t know where. Whenever you purchase any developer product in game, it just adds it to the DataStore queue, and send the infinite requests.
function processReceipt(info)
local plr = game:GetService("Players"):GetPlayerByUserId(info.PlayerId)
if plr then
if info.ProductId == 1728120559 then
-- Logic for product with ID 1728120559
plr.Character.Humanoid.Health = 0
local stats = plr:WaitForChild("leaderstats")
local changeStage = stats and stats:FindFirstChild("Stage")
if changeStage then
changeStage.Value +=1
script.Value.Value = true
end
elseif info.ProductId == 1729065465 then
-- Logic for product with ID 1729065465
plr:WaitForChild("leaderstats").Coins.Value = plr.leaderstats.Coins.Value + 25
plr.Character.Humanoid.Health = 100
game.ReplicatedStorage.PurchaseGood:FireClient(plr)
if script.Value.Value == true then
print("yay")
end
elseif info.ProductId == 1729065464 then
-- Logic for product with ID 1729065464
plr:WaitForChild("leaderstats").Coins.Value = plr.leaderstats.Coins.Value + 50
plr.Character.Humanoid.Health = 100
game.ReplicatedStorage.PurchaseGood:FireClient(plr)
if script.Value.Value == true then
print("yay")
end
elseif info.ProductId == 1729065463 then
-- Logic for product with ID 1729065463
plr:WaitForChild("leaderstats").Coins.Value = plr.leaderstats.Coins.Value + 125
plr.Character.Humanoid.Health = 100
game.ReplicatedStorage.PurchaseGood:FireClient(plr)
if script.Value.Value == true then
print("yay")
end
elseif info.ProductId == 1729065466 then
-- Logic for product with ID 1729065466
plr:WaitForChild("leaderstats").Coins.Value = plr.leaderstats.Coins.Value + 250
plr.Character.Humanoid.Health = 100
game.ReplicatedStorage.PurchaseGood:FireClient(plr)
if script.Value.Value == true then
print("yay")
end
end
return Enum.ProductPurchaseDecision.PurchaseGranted
else
return Enum.ProductPurchaseDecision.NotProcessedYet
end
end
game:GetService("MarketplaceService").ProcessReceipt = processReceipt
I need some help with organizing the script for where to put the “return true” at, in order for the first part of the script to work. (By that I mean the first developer product in the script). With the return true, the number of stage points added with twofold each time, when I’d like it to add by one. Thanks!