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

[Unsolved]Problem with Developer Product?

I got the script Working; But when ever the Player who** bought the weapon dies he/she loses the weapon they bought from Dev Products**. So I want to know how can I give the Player the weapons so he/she won't lose there weapons if they die.

local plr = script.Parent.Parent.Parent.Parent.Parent
local link = game:GetService("MarketplaceService")
deb = 0


script.Parent.MouseButton1Click:connect(function()
local marketId = 21055724
link:PromptProductPurchase(plr,marketId)
link.ProcessReceipt = function(receiptInfo)
if Enum.ProductPurchaseDecision.PurchaseGranted and receiptInfo.PlayerId == plr.userId then
if deb == 0 then
deb = 1
local c = game.Lighting.DualIllumina:Clone()
	c.Parent = plr.Backpack
wait(1)
deb = 0
end
end
end
end)

4 answers

✓ Accepted answer

Clone the tool twice so that one of the tools is in the Backpack and the other one is in the StarterGear. The reason you put one of the tools in StarterGear is that every time you die, StarterGear clones it's children to the Backpack.

1 comment

0

Spongocardo do you mean like this(Coding Down below)

Spongocardo do you mean like this because I tried this a it doesn't seem to work :L but have you got any other solutions that I could try?

local plr = script.Parent.Parent.Parent.Parent.Parent
local link = game:GetService("MarketplaceService")
deb = 0


script.Parent.MouseButton1Click:connect(function()
local marketId = 21055724
link:PromptProductPurchase(plr,marketId)
link.ProcessReceipt = function(receiptInfo)
if Enum.ProductPurchaseDecision.PurchaseGranted and receiptInfo.PlayerId == plr.userId then
if deb == 0 then
deb = 1
local c = game.Lighting.DualIllumina:Clone()
	c.Parent = plr.Backpack
local b = game.Lighting.DualIllumina:Clone()
    b.Parent = plr.StarterPack

wait(1)
deb = 0
end
end
end
end)

3 comments

0

Change plr.StarterPack on line 16 to plr.StarterGear. StarterGear is inside the player, StarterPack is a service in the game. If this helps, please accept my answer.

0

I'll try it and if it works I'll accept your answer.

0

Thank you it works and here.

You can try something like this. I believe CharacterAdded is fired every time someone spawns. I did not test this script, so you may need to debug some things. Like the link to the player and his backpack. Good luck!

local link = game:GetService("MarketplaceService")
deb = 0

game.Players.PlayerAdded:connect(function(plr)
	plr.CharacterAdded:connect(function(character)
		local marketId = 21055724
		link:PromptProductPurchase(plr,marketId)
		link.ProcessReceipt = function(receiptInfo)
			if Enum.ProductPurchaseDecision.PurchaseGranted and receiptInfo.PlayerId == plr.userId then
				if deb == 0 then
					deb = 1
					local c = game.Lighting.DualIllumina:Clone()
					c.Parent = plr.Backpack
					wait(1)
					deb = 0
				end
			end
		end
	end)
end)

1 comment

0

That won't work because he wants it so that you click a button in a GUI to buy the tool. See my answer.

game.Players.LocalPlayer:Died:connect(function()
(Clone the tool and put it in the backpack here)
end)

1 comment

0

Sinblade Thanks for the help but Spongocardo sorted it out for me :)

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