I want to edit my dev. product script to give the player extra health until he leaves the server. How do I go about doing this?
The button script to prompt the purchase works fine. It is only this portion that I need to edit:
local MarketplaceService = game:GetService("MarketplaceService")
local HealthID, PointsID = 89333927
local PurchaseHistory = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
MarketplaceService.ProcessReceipt = function(receiptInfo)
for i, player in ipairs(game.Players:GetChildren()) do
if player.userId == receiptInfo.PlayerId then
if receiptInfo.ProductId == HealthID then
player.Character.Humanoid.MaxHealth = player.Character.Humanoid.MaxHealth + 50
player.Character.Humanoid.Health = player.Character.Humanoid.Health + 50
end
end
end
local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_purchase_" .. receiptInfo.PurchaseId
PurchaseHistory:IncrementAsync(playerProductKey, 1)
return Enum.ProductPurchaseDecision.PurchaseGranted
end
Right now it only gives the said purchaser + 50 health until he or she dies. Then it resets back to 100 MaxHealth and 100 Health.

3 comments
Thank you.
Feel free to accept my answer if this helped you.
Don't forget to also add it when they purchase it, so they aren't forced to reset for it to work.