How can I make a script that, when a part is clicked in the workspace, it creates a selection box for it?

I have been struggling at this for quite a while, I can’t seem to figure out an optimal way to have a player’s mouse click a part and a selection box to appear.

Do you mean like a GUI of sorts? If so, a billboard GUI or a screen GUI?

No, using the “SelectionBox” instance. If you click a part in the workspace, it should be able to show it.

You can use Instance.new to create a SelectionBox.

local ClickDetector = script.Parent.ClickDetector

ClickDetector.MouseClick:Connect(function(player)
local box = Instance.new(“SelectionBox”,script.Parent)
–Edit Properties Here
end)

I know this, but my question is how do I get which part the player clicks from the mouse of the player.

You can also use in a Local Script, local player = game.Players.LocalPlayer, local mouse = player:GetMouse(), mouse.MouseButton1Down:Connect(function(target)

I thought the mouse object is being phased out? besides im using UIS so I dont know if that conflicts.

you should change the question then, your title question is not compared to what you actually want

The mouse doesn’t have to be phased out, and you don’t need UIS. the “Target” in the function is what the player clicks. You can rename your targetPart in workspace, and the “target” in the function becomes that part.

If target.Name == targetPart.Name then
– FireServer
end

MouseButton1Down doesn’t seem to work.
never mind, was just using it wrong