I'm currently following Roblox Documentation here:
https://create.roblox.com/docs/studio/plugins
The script segment that they show as an example is here:
local ChangeHistoryService = game:GetService("ChangeHistoryService")
local Selection = game:GetService("Selection")
-- Create a new toolbar section titled "Custom Script Tools"
local toolbar = plugin:CreateToolbar("Custom Script Tools")
-- Add a toolbar button named "Create Empty Script"
local newScriptButton = toolbar:CreateButton("Create Empty Script", "Create an empty script", "rbxassetid://14978048121")
-- Make button clickable even if 3D viewport is hidden
newScriptButton.ClickableWhenViewportHidden = true
local function onNewScriptButtonClicked()
local selectedObjects = Selection:Get()
local parent = game:GetService("ServerScriptService")
if #selectedObjects > 0 then
parent = selectedObjects[1]
end
local newScript = Instance.new("Script")
newScript.Source = ""
newScript.Parent = parent
ChangeHistoryService:SetWaypoint("Added new empty script")
end
newScriptButton.Click:Connect(onNewScriptButtonClicked)```
The script above is what I am working with.
I'm not sure if it's possible, but I would like to select/click an object/instance in the explorer and having the selection become the parent for the script, instead of hard-coding the parent to 'ServerScriptService'.
Is this possible, and if so, how would I go about doing this? I've tried to research it though I have not come across anything.