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

[SOLVED] Why do I get multiple M1911s...?

Asked by
c0des 207 Moderation Voter
10 years ago

The pictures explain most of it... First Picture (Lightshot), Second Picture (Also Lightshot), Third Picture (Yet Again, Lightshot)

So I really need help figuring out why I receive a random number of M1911's when I purchase the Developer Product.

+Rep to anyone who helps me, with logical/working answers.

If you don't feel like looking at the pictures (even though they explain everything better...),

Here is the LocalScript inside StarterPack:

local buyButton = game.Workspace.BuyButton.SurfaceGui.TextButton
local damageButton = game.Workspace.DamageButton.SurfaceGui.TextButton
local productId = 19635648

buyButton.MouseButton1Click:connect(function()
    game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer, productId)
end)

damageButton.MouseButton1Click:connect(function()
    game.Players.LocalPlayer.Character.Humanoid.Health = game.Players.LocalPlayer.Character.Humanoid.Health - 40
end)

Here is the Script inside Workspace.BuyButton:

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

MarketplaceService.ProcessReceipt = function(receiptInfo) 

    for i, player in ipairs(game.Players:GetChildren()) do

        if player.userId == receiptInfo.PlayerId then

            if receiptInfo.ProductId == productId then
                game.Lighting:FindFirstChild("M1911"):Clone().Parent = player.Backpack
                game.Workspace.DisplayScreen.SurfaceGui.TextBox.Text = player.Name .. " has purchased an illegal M1911."
                wait(2)
                weapons = game.Lighting:FindFirstChild("M1911")
                local c = game.Players:FindFirstChild(player.Name).Backpack:GetChildren()

                for i = 1,#c do
                    if c[i].Name ~= "M1911" then

                    for i = 1, #weapons do
                        if weapons[i].className == "Tool" then
                        weapons[i]:clone().Parent = player.Backpack
                        end
                    end
                end
            end
        end 
    end
end
    local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_purchase_" .. receiptInfo.PurchaseId
    ds:IncrementAsync(playerProductKey, 1)  

    return Enum.ProductPurchaseDecision.PurchaseGranted
end
0
Please post your code in your question, not through a picture. Articulating 1335 — 10y
0
I did it so everyone understood what code went where. Please remove the negative rep... I was trying to make it easier for everyone reading it, so nobody got confused. c0des 207 — 10y
0
Could you also try and help me here? c0des 207 — 10y
0
Are there any errors...? Or is the M1911 model just bugged? c0des 207 — 10y
View all comments (3 more)
0
It has a few issues. I'm not entirely sure of your aim. Articulating 1335 — 10y
0
If you look at the prntscr images, you will see exactly, as it explain everything. c0des 207 — 10y
0
Bumping it. c0des 207 — 10y

2 answers

Log in to vote
0
Answered by 10 years ago

I don't have time to thoroughly look through this but I think I see where the issue is... I think line 15-26 is your issue

        weapons = game.Lighting:FindFirstChild("M1911")
                local c = game.Players:FindFirstChild(player.Name).Backpack:GetChildren()--okay so you look in the players backpack

                for i = 1,#c do --check all the items
                    if c[i].Name ~= "M1911" then--find items in the back that are m1911

                    for i = 1, #weapons do --so for every m1911 model you copy a tool
                        if weapons[i].className == "Tool" then
                        weapons[i]:clone().Parent = player.Backpack--this will eventually add up to a lot
                        end
                    end
                end

Look in that area for your issue. I'll look more into this in a few minutes. Playing League of Legends atm... lol

0
Thanks, I got really messed up because I deleted parts and added more parts and all... It was supposed to see if the M1911 was successfully cloned the first time, and if not, then it would clone it the second time... c0des 207 — 10y
0
Nope... I tried both of your answers, neither worked... c0des 207 — 10y
0
hmmm sorry I haven't looked much into developer product yet. soaprocks2 75 — 10y
Ad
Log in to vote
0
Answered by
c0des 207 Moderation Voter
10 years ago

Can anyone help me...?

0
Solved. c0des 207 — 10y

Answer this question