Issue with Selection Box

  1. What do you want to achieve? Keep it simple and clear!

A selection box that can select parts and highlight them.

  1. What is the issue? Include screenshots / videos if possible!

The selection box doesn’t disappear when user isn’t clicking and dragging.
robloxapp-20230818-1132034.wmv (786.6 KB)

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve tried looking at the forums and the documentation to see what is the problem. I have a feeling that the problem has to do with one of these functions.
mouse.Button1Up:Connect(function()
	if pointBegin and pointEnd then
		local selectedParts = Search(
			workspace.Blue.Cities:GetChildren(), partPosBegin, pointEnd
		);
		selectedCity(cities,selectedParts)
		warn(selectedParts)
	end
	destroyBox()
end)

mouse.Move:Connect(function()
	if pointBegin then
		local endPos = mouse.X
		local endPosY = mouse.Y
		pointEnd = Vector2.new(endPos, endPosY)
		createBox(pointBegin.x, pointEnd.x, pointBegin.Y , pointEnd.y)
	end
end)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

I fixed this issue, I had to make mouse.Move into a local function then make a variable called dragFunction that is equal to

dragFunction = mouse.Move:Connect(function()

After that I disconnected the function when the mouse is released and called the function back when the mouse is pressed down.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.