Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

7 comments

0

Please post your code in your question, not through a picture.

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.

0

Could you also try and help me here?

0

Are there any errors...? Or is the M1911 model just bugged?

0

It has a few issues. I'm not entirely sure of your aim.

0

If you look at the prntscr images, you will see exactly, as it explain everything.

0

Bumping it.

2 answers

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

3 comments

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...

0

Nope... I tried both of your answers, neither worked...

0

hmmm sorry I haven't looked much into developer product yet.

This discussion is preserved as it was. New answers, comments, and votes are closed.