How to detect what your selecting in studio

I am making a plugin that needs a part to be selected. How would I check which part is selected in Studio for this plugin?

Not the games player I mean in studio, as you’ve seen in many others like building plugins, they can detect how to get the part you’ve selected, does anyone know how to do this?

2 Likes

game.Selection:Get() returns an array of all instances that are currently selected in studio.

2 Likes

Additionally, you can force the user to select a group of objects by passing an array into game.Selection:Set()

1 Like

So now I have this,
local toolbar =

    plugin:CreateToolbar("TheBaconHero_101's Plugins")
    local newScriptButton = toolbar:CreateButton("Create AttachmemtPoint for scope", "Creates AttachmemtPoint for scope", "")

    newScriptButton.Click:Connect(function()
    	local Selected = game.Selection:Get()
    	print(Selected)
    	local attachPoint = Instance.new("Attachment")
    	attachPoint.Parent = Selected
    end)

Its printing the part that its getting, but not setting the parent, is there something else I’m supposed to do?

1 Like

“Selected” is going to be an array, so to get the actual part you’d have to index it.

newScriptButton.Click:Connect(function()
    	local Selected = game.Selection:Get()[1]
    	print(Selected)
    	local attachPoint = Instance.new("Attachment")
    	attachPoint.Parent = Selected
    end)
3 Likes