How to Create a "Delete From Inventory" Script

Hello. I’m making an RNG game and have been struggling with the “Delete from Inventory” aspect of the game.

My recent attempts have caused a lot of glitches so this was kind of my last resort.

These are my scripts for the “Inventory” aspect.

Adding Inventory Script
local RS = game:GetService("ReplicatedStorage")
local updateInventoryEvent = RS:WaitForChild("UpdateInventory")

local ScrollingFrame = script.Parent.ScrollingFrame
local EffectTitles = ScrollingFrame:WaitForChild("EffectTitles")

local function addItem(effect)
	
	local clonedTitle = EffectTitles:WaitForChild(effect):Clone()
	clonedTitle.Parent = ScrollingFrame
	clonedTitle.Visible = true
	
end

updateInventoryEvent.OnClientEvent:Connect(addItem)

Directory of the “Adding Inventory” Script:

image

Effect Selection Script
local ScrollingFrame = script.Parent.ScrollingFrame

ScrollingFrame.ChildAdded:Connect(function(child)
	
	if child:IsA("TextButton") then
		child.MouseButton1Up:Connect(function()
			for i, v in pairs(ScrollingFrame:GetChildren()) do
				if v:IsA("TextButton") then
					v.BackgroundTransparency = 1
				end
			end
			child.BackgroundTransparency = 0.75
		end)
	end
	
end)

Directory of the “Effect Selection” Script:

image

I understand that you may need other scripts or something else for further understanding so just know I’m always online if you need anything.

Basically, what I need to achieve is; (not saying any of you have to do all of this for me, but sort of just explain how I can do this)

Features

  • Remove the label from the inventory (without causing any problems when rolling the same aura and having nothing in your inventory since we “removed” the label)

  • Removing the BillboardGui from the players head that shares the name with the selectedEffect

  • Removing the attachment with the particle emitters from the players torso (which also shares the name with the selectedEffect)

Bug Fixing/Troubleshooting

  • Being unable to delete the aura that is currently equipped. (CurrentlyEquippedFolder ← another example of why you would need further context with other scripts I have)

If anyone would be kind enough to help me or just explain to me how I would achieve this, I’m glad to help. And if you need more scripts for context, just let me know.

Thank you so much,
Antlers :two_hearts: