Original feature request was to make SaveSelectedToRoblox return the saved ID, but it might end up causing issues if it was magically changed into a yield function. A better implementation would be to create an entirely new function.
It’d be great if we had a new method added to plugin named SaveToRoblox. It would function similarly to SaveSelectedToRoblox, except SaveToRoblox would be a yield function that returned the ID of the saved asset to enable the creation of “Recent Saves” or similar features in plugins. It would also remove the dependency on selection (not related to asset publishing) for saving assets, meaning plugins like the animation editor would no longer have to set the user’s selection and then unset afterwards to publish assets.
I tried saving a custom animation to ROBLOX, but it wasn’t exactly working. This was my code:
local oldSelection = game.Selection:Get()
game.Selection:Set({animation})
plugin:SaveSelectedToRoblox()
game.Selection:Set(oldSelection)
For some reason, instead of saving the animation, ROBLOX was trying to save my previous selection. The issue ended up being SaveSelectedToRoblox having extremely poor design. Instead of keeping track of what’s selected when the method is called and saving that when “Publish” is pressed, when you press “Publish” it literally saves the current selection instead of what was selected when the method was called – if you call the method, change the selection 5 minutes later, and then publish, it saves the selection you changed to after 5 minutes.
I’m sure @Davidii and @AbstractAlex weren’t very happy about this when designing the official animation editor. It means whenever you export an animation, the plugin selects (a behavior it never exhibits except in this one case) and the explorer zooms to some internal object, and it’s never cleaned up (because it’s impossible to tell when the upload prompt has closed). I’m not very happy either. It’d be great if we had a better alternative.
YieldFunction int AssetService:PromptUploadAsync(Instance, Enum.AssetType) [PluginSecurity]
Returns the assetId if the user successfully uploads the asset
Returns 0 if the user cancels the dialog
Throws an error if failed to upload
I guess we don’t have an explicit way to only compile methods for Studio so we just stuff them in Plugin it clear they won’t work on clients/servers? So maybe this belongs in plugin?
Sounds good! Might want to make Instance a table of Instances though – multiple objects in the user’s selection are able to be uploaded as a single model using Publish To Roblox.
Actually I think it could be beneficial in-game. In @Maelstronomer’s Pilgrim Islands Reborn, players are able to construct anything they want in a manner similar to Minecraft (at least the social aspect of it). Right now he has a policy where you can PM him and he’ll send you your models, but I’m sure it’d be much easier on everyone involved if he could call PromptUploadAsync in-game and players were able to download their stuff on their own. I’m not sure how this would tie in with security though (imagine an exploiter managing to get access to this and downloading the whole game). If there’s even a slight risk with security, it should probably be a member of plugin.