Plugin Asset Permissions

The current way a plugin updates a model or other asset is very inefficient. The user has to go through all the steps of uploading a model each time. This has led me to accidentally creating a new model or updating the wrong model multiple times.

Here’s an example of one of my plugins updating a model:


Notice how I also need to click a button to revert publishing changes, because there’s no way for the plugin to know when the publish is done.

Proposed Solution

Allow users to grant a plugin access to specific assets. This will allow the plugin to update the asset without going through a dialogue. Here’s how this could be implemented:

The plugin prompts the user to select an asset, or create a new one if allowed

Plugin:PromptForAssetPermission(assetType: Enum.AssetType, allowCreateNew: boolean?): number?
--Returns the assetId selected or nil if cancelled

The plugin now has permission for that asset, and can update it at any time

Plugin:SaveToRoblox(object: Instance, assetId: number)
--Yields and errors if the operation fails

The permissions screen for the plugin will let users view and disable asset permissions similar to http request domains.

Here’s an a full example of how this could work:

local button = plugin:CreateToolbar("Example"):CreateButton("Upload Model", "", "")

button.Click:Connect(function()
	local model = workspace:FindFirstChild("Model")
	local assetId = model:GetAttribute("AssetId")

	if not assetId then
		assetId = plugin:PromptForAssetPermission(Enum.AssetType.Model, true)

		if not assetId then return end

		model:SetAttribute("AssetId", assetId)
	end

	model.Name = "PublishReady"

	local s, e = pcall(function()
		plugin:SaveToRoblox(model, assetId)
	end)

	if s then
		print("Publish successful")
	else
		warn("Publish unsuccessful:", e)
	end

	model.Name = "Model"
end)

This solution would solve the problems described in these posts: