-- These are customizeable criteria regarding exactly what is removed, and where it is removed from:

RemoveTools = true
RemoveHopperBins = true
RemoveFromBackpack = true
RemoveFromCharacter = true
RemoveForceField = false

script.Parent.BrickColor = BrickColor.new(21)

function getPlayer(humanoid)
	local players = game.Players:GetChildren()
	for i = 1, #players do
		if (players[i].Character.Humanoid == humanoid) then return players[i] end
	end
	return nil
end

function checkKeeper(player)
	for i = 1,#keepers do
		if (keepers[i] == player.Name) then return true end
	end
	return false
end

function RemoveWeapons(parent)
	local weapons = parent:GetChildren()
	for i = 1,#weapons do
		if (weapons[i].className == "Tool") and (RemoveTools == true) then
			weapons[i]:remove()
			script.Parent.BrickColor = BrickColor.new(22)
		elseif (weapons[i].className == "HopperBin") and (RemoveHopperBins == true) then
			weapons[i]:remove()
			script.Parent.BrickColor = BrickColor.new(22)
		end
	end
end

local debounce = false

function onTouched(hit)
	local human = hit.Parent:findFirstChild("Humanoid")	
	if (human == nil) then return end
	local player = getPlayer(human)
	if (player == nil) then return end

	if (checkKeeper(player) == true) or (debounce == true) then return end

	debounce = true

	if (RemoveFromBackpack == true) then
		local backpack = player.Backpack
		if (table.maxn(backpack:GetChildren()) > 0) then
			RemoveWeapons(backpack)
		end
	end
	
	if (RemoveFromCharacter == true) then
		RemoveWeapons(player.Character)
	end
	
	if (RemoveForceField == true) then
		local charparts = player.Character:GetChildren()
		for i = 1,#charparts do
			if (charparts[i].className == "ForceField") then
				charparts[i]:remove()
				script.Parent.BrickColor = BrickColor.new(22)
			end
		end
	end

	wait(0.5)

	script.Parent.BrickColor = BrickColor.new(21)
	debounce = false
end

script.Parent.Touched:connect(onTouched)
