So... I already have almost working code, but it dont remove current tool. Code:
function onTouch(obj)
if obj.Parent:findFirstChild("Humanoid")~=nil then
p=game.Players:findFirstChild(obj.Parent.Name)
if p~=nil then
ch=p.Backpack:getChildren()
for i = 1, #ch do
if ch[i].Name~="Examine" and ch[i].Name~="Get" and ch[i].Name~="Window" and ch[i].Name~="Mop" and ch[i].Name~="Bathroom" and ch[i].Name~="Water" and ch[i].Name~="Weed" then ch[i]:Remove() end
end
end
end
end
script.Parent.Touched:connect(onTouch)
I found this later:
--made by Mekrik
local giver = script.Parent
--This script will remove all the tools in a Player's inventory
local forceRemoveCurrentTool = true
local useDebounce = true
local debounce = false
function getPlayer(humanoid)
local players = game.Players:children()
for i = 1, #players do
if players[i].Character.Humanoid == humanoid then return players[i] end
end
return nil
end
function onTouch(part)
if part.Parent ~= nil then
local human = part.Parent:findFirstChild("Humanoid")
if (human ~= nil) and debounce == false then
debounce = true
local player = getPlayer(human)
if (player == nil) then return end
local tools = player.Backpack:GetChildren()
for i = 1, #tools do
local tool = tools[i]
if tool:IsA("Tool") or tool:IsA("HopperBin") then
tool:Destroy()
end
end
local char = player.Character
if char ~= nil and forceRemoveCurrentTool then
local charStuff = char:GetChildren()
for i = 1, #charStuff do
local obj = charStuff[i]
if obj:IsA("Tool") or obj:IsA("HopperBin") then
obj:Destroy()
end
end
end
wait(2)
debounce = false
end
end
end
giver.Touched:connect(onTouch) --The end
It removes current tool but it breaks game and that tool (guis and etc. still on screen, paths wont disappear). So i need to unequip tool first... But i dont know how...
