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)

4 comments
Lol thanks.
Works1
Wouldn't you want to put the while loop outside the click event?
Yeah if you put it in a function then run that function every time the click event happens.