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

I am trying to get my Dev products to give Speed,Money,Health and such but there is a problem?

Asked by 9 years ago

I have this Perk Shop script:

local MarketplaceService = game:GetService("MarketplaceService")
    local AddHealthID = 20433249 --ENTER
    local AddSpeedID = 20438665  --PASS
    local AddGearID = 21739855   --IDS
    local AddGear2ID = 21739858   --IDS
    local AddGear3ID = 21739864  --HERE
    local PurchaseHistory = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
    MarketplaceService.ProcessReceipt = function(receiptInfo)
        local playerProductKey = receiptInfo.PlayerId .. ":" .. receiptInfo.PurchaseId
        if PurchaseHistory:GetAsync(playerProductKey) then
            return Enum.ProductPurchaseDecision.PurchaseGranted
        end
        for i, player in ipairs(game.Players:GetPlayers()) do
            if player.userId == receiptInfo.PlayerId then
                if receiptInfo.ProductId == AddHealthID then
                    player.Character.Humanoid.MaxHealth = player.Character.Humanoid.MaxHealth + 50 --Adds 50 to their current health
                    player.Character.Humanoid.Health = player.Character.Humanoid.MaxHealth
                end
                if receiptInfo.ProductId == AddSpeedID then
                    player.Character.Humanoid.WalkSpeed = player.Character.Humanoid.WalkSpeed + 15 -- Adds 5 to their current Walkspeed
                end
                if receiptInfo.ProductId == AddGearID then
                    game.ReplicatedStorage.DualVenomshanks:Clone().Parent = player.Backpack -- put the gear in ReplicatedStorage then put the name of the gear in the GEARNAMEHERE
                    -- game.ReplicatedStorage.GEARNAMEHERE:Clone().Parent = player.StarterGear -- Add this back in if you want them to get this item till they leave the game, Like renting it
              end
                if receiptInfo.ProductId == AddGear2ID then
                    game.ReplicatedStorage.GravityCoil:Clone().Parent = player.Backpack -- put the gear in ReplicatedStorage then put the name of the gear in the GEARNAMEHERE
                    -- game.ReplicatedStorage.GEARNAMEHERE:Clone().Parent = player.StarterGear -- Add this back in if you want them to get this item till they leave the game, Like renting it
                end
                if receiptInfo.ProductId == AddGear3ID then
                    game.ReplicatedStorage.Jetpack:Clone().Parent = player.Backpack -- put the gear in ReplicatedStorage then put the name of the gear in the GEARNAMEHERE
                    -- game.ReplicatedStorage.GEARNAMEHERE:Clone().Parent = player.StarterGear -- Add this back in if you want them to get this item till they leave the game, Like renting it
                end
            end
        end
        PurchaseHistory:SetAsync(playerProductKey, true)   
        return Enum.ProductPurchaseDecision.PurchaseGranted
    end

And then this in starterpack so that the cash perk will work:

local MarketplaceService = Game:GetService("MarketplaceService")
    local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")

    CASHID = 00000000 -- Put the ID of the Developer Product here. Dont forget to erase the 0's.

    MarketplaceService.ProcessReceipt = function(receiptInfo)
        local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_product_" .. receiptInfo.ProductId
        local numberBought = ds:IncrementAsync(playerProductKey, 1)
        for i,v in pairs (game.Players:GetChildren()) do
            if v.userId == receiptInfo.PlayerId then
                if receiptInfo.ProductId == CASHID then


                    lds = v:FindFirstChild("leaderstats")
                    if lds ~= nil then
                        cs = lds:FindFirstChild("Coins") --Change to your leaderstat that you want it to add to.
                        if cs ~= nil then
                            cs.Value = cs.Value + 1000 --Change to the amount of Coins you want to add.
                        end
                    end
                end
            end
        end
        return Enum.ProductPurchaseDecision.PurchaseGranted    
    end


                    -- Put this script in the Starter Pack when you are done editing it :)

There is one problem, the second script causes the top one not to work. Maybe because it is in starterpack. Help if you can because i dont know how to fix it....

Answer this question