Hi everyone I’m currently working on an Inventory System and my Part I’m working on now is how to delete a Tool from the Inventory so rn if I press on a Tool in my Inventory I can see the Name of the Tool, I can equip the Tool and I can press on an Delete Button which leads me to a SureFrame that gives u the last Chance for not deleting/deleting the Tool here r some pics:(Can y’all tell me me what exactly I have to do like paste the script and the remote event cuz I’m a noob at scripting but only do it If u don’t mind and if it’s easy)
When I press on a Tool:
When I press on the Delete Button:
So this is how it works and when I press on the Cancel Button the Frame sets automatically Visible to false now what I need to function is that when I press on the “Yes” Button which should be the Parent of the Local Script(I can tell the exact position of the Button if u want) the Tool should automatically get deleted I think everyone knows what I mean now I got a Script here which is located in the ServerScriptService he should have all elements u guys need I think I got another LocalScript in the InventoryFrame but he isn’t useful I believe now the Script:
local inventoryEvent = game.ReplicatedStorage.Remotes.InventoryEvent
game.Players.PlayerAdded:Connect(function(player)
local inventory = player:WaitForChild("Inventory")
local inventoryFrame = player.PlayerGui:WaitForChild("InventoryGui").InventoryFrame.ItemsFrame:GetChildren()
inventory.ChildAdded:Connect(function(Item)
inventoryEvent:FireClient(player, Item.Name, true)
end)
end)
inventoryEvent.OnServerEvent:Connect(function(player, ItemName, Value, button)
if Value == false then
local SelectedItem = player.Inventory:FindFirstChild(ItemName)
local backpack = player.Backpack:GetChildren()
local stuff = player.Character:GetChildren()
if #backpack == 0 and not player.Character:FindFirstChildWhichIsA("Tool") then
button.Text = "Unequip"
button.BackgroundColor3 = Color3.new(255,0,0)
SelectedItem:Clone().Parent = player.Backpack
else
for i,v in ipairs(backpack) do
button.Text = "Equip"
button.BackgroundColor3 = Color3.new(0,255,0)
v:Destroy()
end
for i, v in ipairs(stuff) do
if v:IsA("Tool") then
button.Text = "Equip"
button.BackgroundColor3 = Color3.new(0,255,0)
v:Destroy()
end
end
end
end
end)