Hello!
I need your help to find how to break this loop in line 3 when I release mouse button:
script.Parent.Equipped:connect(function(mouse) mouse.Button1Down:connect(function() while mouse.Button1Down do wait() if mouse.Target.Name == "DrawBoard" then local instspr = Instance.new("Part") instspr.Parent = mouse.Target instspr.CFrame = CFrame.new(mouse.Hit.p) * CFrame.new(0, 0.1, 0) instspr.Anchored = true instspr.CanCollide = false instspr.BrickColor = BrickColor.new("Institutional white") instspr.Name = "DrawPix" instspr.FormFactor = Enum.FormFactor.Custom instspr.Size = Vector3.new(0.2, 0.2, 0.2) instspr.BottomSurface = Enum.SurfaceType.Smooth instspr.TopSurface = Enum.SurfaceType.Smooth end end end) end)
A debounce.
mouse.Button1Down:connect(function() down = true --Setting down to true before the loop starts while down do -- While down is true it will loop --stuff end end) mouse.Button1Up:connect(function() down = false --When button it released it sets down to false thus breaking the loop end)