Hiya all. So, what happens when somebody buys this dev product, it awards +10 speed. And when you die, you lose it. The problem is say you have 56 walkspeed because you bought it 4 times, then you die. Say you buy another +10 after you die. It awards you all the old walkspeed as well and the new +10, then giving you 66 Walkspeed (just an example). How can I make it so you can't get all of that back after death? So say if you bought another +10 after death you only have 26 WalkSpeed? Thanks!
This script is in the Workspace, in case anyone needs to know what.
local developerProduct = 20338463 -- Id of the developer product local speedInc = 10 --Change this to the amount of Walkspeed you'd like to give. Game:GetService("MarketplaceService").ProcessReceipt = function(receipt) if receipt.ProductId == developerProduct then -- the speed dev product for i,v in pairs(game.Players:GetPlayers()) do -- loop through the players if v.userId == receipt.PlayerId then -- if they're the player that bought it if v.Character and v.Character:FindFirstChild("Humanoid") then v.Character.Humanoid.WalkSpeed = v.Character.Humanoid.WalkSpeed + 10 -- add speedinc to their current walkspeed end end end end end
You want to add this line of code just before the last end on line 14 of your code.
return Enum.ProductPurchaseDecision.PurchaseGranted
I have encountered a similar situation where my script would give me 1000 credits continuously on entry to the game. I hope this helps.