I want to make it so when you like hold the left click button on your mouse, it would create a square that would select multiple parts, depending on the range of how big you made the square while holding left mouse button. How do I do it? What things do I need.
function onClicked() end script.Parent.ClickDetector.MouseClick:connect(onClicked)
local player = game.Players.LocalPlayer local mouse = player:GetMouse() local selectedparts = {} --[[ This is an array, I made it so that you can store the selected parts and modify them. --]] mouse.Button1Down:connect(function() if mouse.Target ~= nil then local object = mouse.Target local selectionbox = Instance.new("SelectionBox", object) selectionbox.Adornee = object table.insert(selectedparts, object) end end) local function cleararray() --Call this function to clear the selected parts cleararray() for i,v in pairs(selectedparts) do if v:FindFirstChild("SelectionBox") then v:Destroy() end end selectedparts = {} end
This script will select the parts you click on. I'm not sure how to make a script where you can click and drag to select. But I assume it would have something to do with Region3's. But either way, I hope this can help you.