I have a developer purchase which activates and says successful but will not give the lives to the character for the purchase here is the two scripts im using for the leaderboard and the purchase.
Here is the Leaderboard Script
game.Players.PlayerAdded:Connect(function(plr) local Stats = Instance.new('Folder') Stats.Name = 'leaderstats' Stats.Parent = plr local Lives = Instance.new('IntValue') Lives.Name = 'Souls' Lives.Value = 25 Lives.Parent = Stats local Stage = Instance.new('IntValue') Stage.Name = 'Stage' Stage.Value = 0 Stage.Parent = Stats local Timer = Instance.new('IntValue') Timer.Name = 'Time' Timer.Value = 0 Timer.Parent = Stats plr.CharacterAdded:Connect(function(char) char.Humanoid.Died:Connect(function() Lives.Value = Lives.Value -1 if Lives.Value <= 0 then char:SetPrimaryPartCFrame(workspace.Starter.CFrame) Stage.Value = 0 Lives.Value = 25 end end) end) while true do wait(1) Timer.Value = Timer.Value +1 end end)
Here is the Purchase Script
local Lives = game.Workspace.Leaderboard local mpService = game.getService("MarketplaceService") mpService.ProcessReceipt = function(purchaseInfo) local plr = game:GetService("Players"):GetPlayerByUserId(purchaseInfo.PlayerId) if purchaseInfo.ProductId == 55131820 then Lives.Value = Lives.Value +1 end return Enum.ProductPurchaseDecision.PurchaseGranted end
If anyone can help me figure out what is wrong it would be great. I've been stuck on this for awhile now and can't get past it. Thank you
It looks like you are incrementing the wrong value.
In your leaderstats code, 'Lives' was actually named 'Souls' on line 7
. So, on line 7 of the Purchase script, index the 'Souls' object from plr's leaderstats and you should be good.
local mpService = game.getService("MarketplaceService") mpService.ProcessReceipt = function(purchaseInfo) local plr = game,Players:GetPlayerByUserId(purchaseInfo.PlayerId) if purchaseInfo.ProductId == 55131820 then --The value that will be incremented local Lives = plr.leaderstats.Souls; Lives.Value = Lives.Value +1 end return Enum.ProductPurchaseDecision.PurchaseGranted end