Hello made my first plugin. Converts your mesh to special mesh. Mostly for vfx artists to save a couple clicks. Looking for critique in my code and additive features I could add.
Currently takes all selected mesh and converts the properties. Had trouble with change-history service. Undo worked, but didn’t revert back to the original mesh instance, just deleted it.
plugin: https://create.roblox.com/store/asset/17597221422/EzMesh
Source code:
local Selection = game:GetService('Selection')
local ChangeHistoryService = game:GetService('ChangeHistoryService')
local toolBar = plugin:CreateToolbar('EzMesh') :: {PluginToolbarButton}
local button = toolBar:CreateButton('Create', 'Convert mesh into special mesh', '') :: {PluginToolbarButton}
button.Click:Connect(function()
local IsRecordingInProgress = ChangeHistoryService:IsRecordingInProgress() :: {ChangeHistoryService}
if IsRecordingInProgress then
return
end
local selected = Selection:Get()
for i, mesh in selected do
if mesh:IsA('MeshPart') then
local meshName = mesh.Name
local meshSize = mesh.Size
local meshPosition = mesh.Position
local meshId = mesh.MeshId
local part = Instance.new('Part', workspace)
local specialMesh = Instance.new('SpecialMesh', part)
part.Name = mesh.Name
part.Position = meshPosition
part.Size = meshSize
specialMesh.MeshId = meshId
mesh:Destroy()
end
end
local recording = ChangeHistoryService:TryBeginRecording('SpecialMesh created')
if not recording then
warn('Error. Could not make changes. Please try again.')
ChangeHistoryService:FinishRecording(recording, Enum.FinishRecordingOperation.Cancel)
return
end
ChangeHistoryService:FinishRecording(recording, Enum.FinishRecordingOperation.Commit)
end)