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
11 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:

01local buyButton = game.Workspace.BuyButton.SurfaceGui.TextButton
02local damageButton = game.Workspace.DamageButton.SurfaceGui.TextButton
03local productId = 19635648
04 
05buyButton.MouseButton1Click:connect(function()
06    game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer, productId)
07end)
08 
09damageButton.MouseButton1Click:connect(function()
10    game.Players.LocalPlayer.Character.Humanoid.Health = game.Players.LocalPlayer.Character.Humanoid.Health - 40
11end)

Here is the Script inside Workspace.BuyButton:

01local MarketplaceService = Game:GetService("MarketplaceService")
02local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
03local productId = 19635648
04 
05MarketplaceService.ProcessReceipt = function(receiptInfo)
06 
07    for i, player in ipairs(game.Players:GetChildren()) do
08 
09        if player.userId == receiptInfo.PlayerId then
10 
11            if receiptInfo.ProductId == productId then
12                game.Lighting:FindFirstChild("M1911"):Clone().Parent = player.Backpack
13                game.Workspace.DisplayScreen.SurfaceGui.TextBox.Text = player.Name .. " has purchased an illegal M1911."
14                wait(2)
15                weapons = game.Lighting:FindFirstChild("M1911")
View all 35 lines...
0
Please post your code in your question, not through a picture. Articulating 1335 — 11y
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 — 11y
0
Could you also try and help me here? c0des 207 — 11y
0
Are there any errors...? Or is the M1911 model just bugged? c0des 207 — 11y
View all comments (3 more)
0
It has a few issues. I'm not entirely sure of your aim. Articulating 1335 — 11y
0
If you look at the prntscr images, you will see exactly, as it explain everything. c0des 207 — 11y
0
Bumping it. c0des 207 — 11y

2 answers

Log in to vote
0
Answered by 11 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

01weapons = game.Lighting:FindFirstChild("M1911")
02        local c = game.Players:FindFirstChild(player.Name).Backpack:GetChildren()--okay so you look in the players backpack
03 
04        for i = 1,#c do --check all the items
05            if c[i].Name ~= "M1911" then--find items in the back that are m1911
06 
07            for i = 1, #weapons do --so for every m1911 model you copy a tool
08                if weapons[i].className == "Tool" then
09                weapons[i]:clone().Parent = player.Backpack--this will eventually add up to a lot
10                end
11            end
12        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 — 11y
0
Nope... I tried both of your answers, neither worked... c0des 207 — 11y
0
hmmm sorry I haven't looked much into developer product yet. soaprocks2 75 — 11y
Ad
Log in to vote
0
Answered by
c0des 207 Moderation Voter
11 years ago

Can anyone help me...?

0
Solved. c0des 207 — 11y

Answer this question