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

How to remove a specific item in the backpack?

I want to remove an item called "gun" from my backpack when i pass through a transparent part. How do you do this. I have found code to delete the entire inventory, but i would like to just delete the specific item.

1 comment

0

Try, game.Players.LocalPlayer.Backpack:FindFirstChild("gun"):Destroy()

1 answer

You could try this in a script inside the transparent part:

local itemName = "gun"
script.Parent.Touched:Connect(function(hit)
	local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
	if plr then
		local gun = plr.Backpack:FindFirstChild(itemName) or plr.Character:FindFirstChild(itemName)
		if gun then
			gun:Destroy()
		end
	end
end)

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