Does anyone know how i could replicate roblox’s selection outlines for my game? I though this would be pretty simple to accomplish with highlights but the results aren’t as great as i hoped (examples below).
Studio version:
My version:
(long part selected but selection outline hidden)
(camera has ben adjusted but only part of the long part’s selection is visible)
My code:
local mouse = game.Players.LocalPlayer:GetMouse()
local targetChanged = false
local target = nil
local selectedPart = nil
local selection = script.Selection
local selected = script.SelectionSelected
mouse.Button1Down:Connect(function()
if mouse.Target ~= nil then
selectedPart = mouse.Target
selection.Parent = script
selected.Parent = selectedPart
else
selectedPart = nil
selected.Parent = script
end
end)
while task.wait(.1) do
if mouse.Target ~= target then
targetChanged = true
end
if mouse.Target == selectedPart and selectedPart ~= nil then
target = mouse.Target
end
target = mouse.Target
if targetChanged and target ~= nil then
targetChanged = false
selection.Parent = target
elseif target == nil then
selection.Parent = script
end
end
(I’d prefer to keep using highlights since they look better and they’re set to always on top since that’s what helps me get the most desireable effect, pls let me know if you think this is impossible.)



