PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience

View a plugin’s source code

View a plugin’s source code

Sep 20 2018, 3:28 AM PST

If you want to view a plugin’s source code without installing it, you can use DataModel/GetObjects to download the plugin. The code sample below includes a function that will take a plugin’s website URL and insert the plugin into the currently selected Instance or the Workspace.

Due to DataModel/GetObjects|GetObjects’ security context, this function can only be used in the command line or in a plugin.

local Selection = game:GetService("Selection")

local function downloadPlugin(webURL)
    -- get the content URL
    local contentID = string.match(webURL, "%d+")
    local contentURL = "rbxassetid://"..contentID

    -- download the objects
    local objects = game:GetObjects(contentURL)

    -- decide where to parent them
    local selection = Selection:Get()
    local parent = #selection == 1 and selection[1] or workspace

    -- parent the objects
    for _, object in pairs(objects) do
        object.Parent = parent
    end
end