AssignClass Certain Tool

  1. What do you want to achieve? Keep it simple and clear!

I want to achive withing Tool that don’t remove from Gui, Is it Classes Gun
I want a certain tool(name) that don’t remove from Player.Backpack,Tool stay and other will remove.

  1. What is the issue? Include screenshots / videos if possible!
AssignClass Script

player = script.Parent.Parent.Parent
backpack = player.Backpack

function chooseClass(class)
for i, v in pairs(backpack:GetChildren()) do v:remove() end
for i, v in pairs(class:GetChildren()) do
if v:IsA(“Tool”) then
v:clone().Parent = backpack
elseif v:IsA(“HopperBin”) then
v:clone().Parent = backpack
end --classes dissapear – info dissapears also

for i, v in pairs(script.Parent.Box:GetChildren()) do
v.MouseButton1Up:connect(function () chooseClass(v) end)

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I searched Tool remover with specified, to use that script to modify into that script.

Tool remover Script

for i = 1, #ch do
if ch[i].Name~=“Reset” and ch[i].Name==“BuildInsert” and ch[i].Name~=“ToolName” and ch[i].Name~=“ToolName” and ch[i].Name~=“ToolName” and ch[i].Name~=“ToolName” and ch[i].Name~=“ToolName” then ch[i]:Remove() end

I don’t understand between with ~= and == Need help from the script, that i don’t want a certain Tool remove and other will. Need help with those, I don’t know if im doing right.

If you don’t undertstand, please reply here.

1 Like

Remove - Roblox Studio 12_24_2019 6_17_42 PM

1 Like

Your code seems to be very legacy-like. I noticed the presence of several deprecated items existing in your code, such as using remove (Destroy is standard now) and HopperBins (superseded by tools without handles). You ought to clean that up.

Anyhow. You pretty much already have your script, it’s just that you never added a check to see if the tool name was “Protect Me” before removing it. A little bit clunky and I’d prefer other methods of doing that but it’s good enough.

For terms, these are things you can search up with a few seconds of your time. ~= is the negation of equality, so it’s read “if the first thing is not equal to the second thing”. == is an equality check, read as “if the first thing is equal to the second thing”.

Also… please don’t use server scripts in a Gui. Change to a LocalScript and use remotes to communicate with the server sensitive changes.

1 Like

to clear a players tools you could do, if working with data stores , on the Server

   --just giving an example
local players = game:GetService("Players")

    for _, player in ipairs(players:GetPlayers())do
	  --or you could do to remove a specific tool..
		 local to_be_removed = {
		       for _,tool in ipairs(player.Backpack:GetChildren()) do
			 if table.find(tool,to_be_removed)then 
				 tool:Destroy()--destroy a specific tool
1 Like