Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Using mouse.target and tool.activated causing massive lag?

Asked by 3 years ago

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)
0
probably because of the Move function Pupppy44 671 — 3y
0
moved the debounce to before the move function and still have lots of lag icymanred1 6 — 3y

Answer this question