Right now I'm in the process of trying to recreate a btools script. I am starting on the delete tool and it is all working perfectly except, that when you try to use it in an area with no parts, it causes massive amounts of lag. When you use the tool for the first time, there seems to be little lag but after you use it a bit then it starts to break. Does anyone know what I can do to stop this from lagging out completely. Here is the script that is causing the lag:


local db = true
local tool = script.Parent
local mouse = game.Players.LocalPlayer:GetMouse()
local cursel = Instance.new("SelectionBox", workspace)
tool.Equipped:Connect(function(mouse)
	mouse.Move:Connect(function()
		cursel.Adornee = mouse.Target
		cursel.Color = BrickColor.Red()
		if db == true then
			if cursel.Adornee ~= nil then
				tool.Activated:Connect(function()
					local target = mouse.Target
					cursel.Adornee:Destroy()
					cursel.Adornee = nil
					print("e")
					db = false
					wait(0.1)
					db = true

				end)
			end
			
		end
	end)	
end)


tool.Unequipped:Connect(function()
	cursel.Adornee = nil
end)

2 comments

0

probably because of the Move function

0

moved the debounce to before the move function and still have lots of lag