So I have a script that deletes newly added tools, however it doesnt work sometimes because when I pick up a tool it auto-equips which means it goes to the character first instead of the backpack which means it won’t get deleted. Yes I have tried if anything is added to the character but that just makes it so when you equip the tool it gets deleted. Please Help.
local players = game:GetService("Players")
local player = players.LocalPlayer or players.PlayerAdded:Wait()
local character = player.Character or player.CharacterAdded:Wait()
local backpack = player:WaitForChild("Backpack")
local function randNum()
return math.random(-4, 4)
end
backpack.ChildAdded:Connect(function(child)
local toolCount = #backpack:GetChildren()
if toolCount > 1 then
child:Destroy()
end
end)
player.Character.ChildAdded:Connect(function(child)
local toolCount = #backpack:GetChildren()
if child:IsA("Tool") then
wait(0.5)
if toolCount > 1 or toolCount == 1 then
child:Destroy()
end
end
end)
thanks