GUI Part Selection Box

I am a beginner developer and I want for tools in my building themed game to select parts just how it’s done in f3x tools, the particular problem I stumbled upon is making a GUI Selection Box - when you would hold shift and drag your mouse across the screen creating the area in which the parts are selected.

Going through hundreds of lines of code in f3x tools made me incredibly overwhelmed, so I ended up finding this post with the solution, however I do not completely understand how it works and therefore how to adjust it to my tools:

What do Slope1 and Slope2 particularly represent and what property of what instance should I assign them to, if that’s what they are meant for? How do I entangle the script to a Frame to make the selection area visible? Shouldn’t the Frame’s size constantly update while the Mouse is moving and how to achieve that?

Sorry if I asked too many questions!
I will be forever thankful for an explanation.

Hello!

Welcome to the world of developing! :slight_smile:

Are you trying to say that you’d like to have a selectionbox appear for only one player, based on which they have their mouse on?

If yes, this is how I’d do it:

  • Get the mouse
  • Each half of a second (or when they click for example), get the mouse.target (that returns the part they’re pointing to)
  • Using a localscript insert a selectionBox. :slight_smile:

When using a localscript it’s not visible for other players!

 --In ReplicatedStorage insert a SeletionBox make the selection box properties to your needs
 local SelectionBox = game:GetService("ReplicatedStorage").SelectionBox -- The location of your selection box
 local Player = game.Players.LocalPlayer -- Gets the player locally.
 local Mouse = Player:GetMouse() -- Gets the players mouse
 -- Thats all the boring stuff done

 Mouse.Move:Connect(function() -- function for when the mouse is moved

local target = workspace:FindPartOnRay(
	Ray.new(Mouse.UnitRay.Origin,Mouse.UnitRay.Direction*50000)) -- Checks what part the mouse is currently on		 
if not target then
	print("ok then")
else
	if target:IsA("Part") then -- If the target is a part
		SelectionBox:Clone().Parent = target -- Makes it so there is an outline around the part

	else
		local Check = target:FindFirstChild("SelectionBox") -- If the part has a selectionbox 
		if Check then -- Checks if it has it
			target.SelectionBox:Destroy() -- Destroys it
		end
	end
  end
end)

That should work please feel free to ask me if you don’t understand anything in this script.

Thanks for replies, that is something I have already been able to make for my selection, here is a little demo:


The only remaining feature of the selection that I am struggling with and which I meant by GUI Selection Box is like a Lasso tool, here is how it works in F3X:

Google’s your best friend, proven this statement again. After a few clicks on Google, I found this for you:

Hopefully that helps you further!

1 Like