PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience

Selection Boxes

Selection Boxes

5 min

This is a tutorial on how to use a SelectionBox and a few examples of it in use.

SelectionBox require a parent, like all objects and an PVAdornment/Adornee. You can place the SelectionBox wherever you want as its parent, but you must set its adornee. An adornee what it shows up on, so basically it makes it overlay onto the part. Here’s an example of how to create it and set its adornee:

local part = Instance.new("Part",workspace)
part.Anchored = true
part.Size = Vector3.new(5,5,5)

local selectionBox = Instance.new("SelectionBox")
selectionBox.Adornee = part
selectionBox.Color3 = Color3.new(1,0,0)
selectionBox.Parent = part

SelectionBoxExample.jpg

Part selection using a mouse

For this, you just insert a LocalScript into StarterGui, which will be cloned to the Player’s PlayerGui and when they bring their mouse over a part, it will have the SelectionBox over the part their mouse is over. It is also a good starting script that you could easily convert into a tool that does something, this is just a base script that can be expanded to anything you want.

Tags:
  • coding
  • ui