Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-2

Help with this script?

Asked by
Tixy12 0
10 years ago

So I am having problems with my script that adds speed when you buy the speed Developer Product and it works it give you the speed and when you die it is gone. But the other day I found a problem where when you rejoin all that speed you have bought whas given to you again. Say you bought the +10 speed 4 times when you rejoin you would have 40 speed added even though you died with it last game. I want it to where when you buy it you get it but when you die you lose it forever until you buy more .

Please help thanks :)

Script here :

local developerProduct = 20433249

local speedInc = 15 

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 + speedInc -- add speedinc to their current walkspeed
                end
            end
        end
    end
end

Answer this question