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
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.
local modelMode = false -- if true, select models rather than parts local player = game.Players.LocalPlayer local mouse = player:GetMouse() --Getting the player's mouse local selection = Instance.new("SelectionBox") selection.Color3 = Color3.new(0.6,0.6,0,6) selection.Parent = player.PlayerGui mouse.Move:Connect(function() --When the mouse moves local target = mouse.Target if not target then -- nothing selected selection.Adornee = nil elseif modelMode then -- when in model mode, try and select the parents first if target.Parent:IsA("Model") then selection.Adornee = target.Parent elseif target.Parent.Parent:IsA("Accoutrement") then selection.Adornee = target.Parent.Parent elseif target:IsA("BasePart") then selection.Adornee = target else selection.Adornee = nil end else if target:IsA("BasePart") then selection.Adornee = target else selection.Adornee = nil end end end)