Is there a way to make this take up less lines

I made a code that can turn instances into code by selecting and then pressing the plugin button. Here I have used workspace:

-- v1.8
local SerializedTable = {}
local function InsertSerial()
	SerializedTable[`Workspace`] = Instance.new(`Workspace`)
	SerializedTable[`Camera`] = Instance.new(`Camera`)
	SerializedTable[`Baseplate`] = Instance.new(`Part`)
	SerializedTable[`Terrain`] = Instance.new(`Terrain`)
	SerializedTable[`aud`] = Instance.new(`Folder`)
	SerializedTable[`AudioChorus`] = Instance.new(`AudioChorus`)
	SerializedTable[`AudioCompressor`] = Instance.new(`AudioCompressor`)
	SerializedTable[`AudioAnalyzer`] = Instance.new(`AudioAnalyzer`)
	SerializedTable[`AudioChannelMixer`] = Instance.new(`AudioChannelMixer`)
	SerializedTable[`AudioChannelSplitter`] = Instance.new(`AudioChannelSplitter`)
	SerializedTable[`AudioDistortion`] = Instance.new(`AudioDistortion`)
	SerializedTable[`AudioEcho`] = Instance.new(`AudioEcho`)
	SerializedTable[`AudioEqualizer`] = Instance.new(`AudioEqualizer`)
	SerializedTable[`AudioFilter`] = Instance.new(`AudioFilter`)
	SerializedTable[`AudioFader`] = Instance.new(`AudioFader`)
	SerializedTable[`AudioFlanger`] = Instance.new(`AudioFlanger`)
	SerializedTable[`AudioReverb`] = Instance.new(`AudioReverb`)
	SerializedTable[`AudioPitchShifter`] = Instance.new(`AudioPitchShifter`)
	SerializedTable[`AudioLimiter`] = Instance.new(`AudioLimiter`)
	SerializedTable[`val`] = Instance.new(`Folder`)
	SerializedTable[`Value`] = Instance.new(`BoolValue`)
	SerializedTable[`24`] = Instance.new(`BrickColorValue`)
	SerializedTable[`25`] = Instance.new(`CFrameValue`)
	SerializedTable[`26`] = Instance.new(`Color3Value`)
	SerializedTable[`27`] = Instance.new(`IntValue`)
	SerializedTable[`28`] = Instance.new(`RayValue`)
	SerializedTable[`29`] = Instance.new(`Vector3Value`)
	SerializedTable[`Part`] = Instance.new(`Part`)
	SerializedTable[`31`] = Instance.new(`Part`)
	SerializedTable[`32`] = Instance.new(`Part`)
	SerializedTable[`33`] = Instance.new(`Part`)
	SerializedTable[`34`] = Instance.new(`Part`)
	SerializedTable[`35`] = Instance.new(`Part`)
	SerializedTable[`36`] = Instance.new(`Part`)
	SerializedTable[`37`] = Instance.new(`Part`)
	SerializedTable[`38`] = Instance.new(`Part`)
	SerializedTable[`39`] = Instance.new(`Part`)
	SerializedTable[`40`] = Instance.new(`Part`)
	SerializedTable[`41`] = Instance.new(`Part`)
	SerializedTable[`42`] = Instance.new(`Part`)
	SerializedTable[`43`] = Instance.new(`Part`)
	SerializedTable[`44`] = Instance.new(`Part`)
	SerializedTable[`45`] = Instance.new(`Part`)
	SerializedTable[`46`] = Instance.new(`Part`)
	SerializedTable[`47`] = Instance.new(`Part`)
	SerializedTable[`Camera`].DiagonalFieldOfView=127.86448669433594 -- number
	SerializedTable[`Camera`].MaxAxisFieldOfView=102.5256118774414 -- number
	SerializedTable[`Camera`].Parent=SerializedTable[`Workspace`] -- Instance
	SerializedTable[`Baseplate`].FormFactor=Enum.FormFactor.Symmetric -- EnumItem
	SerializedTable[`Baseplate`].Name=[======[Baseplate]======] -- string
	SerializedTable[`Baseplate`].Parent=SerializedTable[`Workspace`] -- Instance
	SerializedTable[`Baseplate`].Anchored=true -- boolean
	SerializedTable[`Baseplate`].Color=Color3.new(0.38823530077934265,0.37254902720451355,0.3843137323856354) -- Color3
	SerializedTable[`Baseplate`].Locked=true -- boolean
	SerializedTable[`Terrain`].WaterColor=Color3.new(0.0470588281750679,0.3294117748737335,0.3607843220233917) -- Color3
	SerializedTable[`Terrain`].Parent=SerializedTable[`Workspace`] -- Instance
	SerializedTable[`aud`].Name=[======[aud]======] -- string
	SerializedTable[`aud`].Parent=SerializedTable[`Workspace`] -- Instance
	SerializedTable[`AudioChorus`].Parent=SerializedTable[`aud`] -- Instance
	SerializedTable[`AudioCompressor`].Parent=SerializedTable[`aud`] -- Instance
	SerializedTable[`AudioAnalyzer`].Parent=SerializedTable[`aud`] -- Instance
	SerializedTable[`AudioDistortion`].Parent=SerializedTable[`aud`] -- Instance
	SerializedTable[`AudioEcho`].Parent=SerializedTable[`aud`] -- Instance
	SerializedTable[`AudioEqualizer`].Parent=SerializedTable[`aud`] -- Instance
	SerializedTable[`AudioFader`].Parent=SerializedTable[`aud`] -- Instance
	SerializedTable[`AudioFlanger`].Parent=SerializedTable[`aud`] -- Instance
	SerializedTable[`AudioReverb`].Parent=SerializedTable[`aud`] -- Instance
	SerializedTable[`AudioPitchShifter`].Parent=SerializedTable[`aud`] -- Instance
	SerializedTable[`val`].Name=[======[val]======] -- string
	SerializedTable[`val`].Parent=SerializedTable[`Workspace`] -- Instance
	SerializedTable[`Value`].Parent=SerializedTable[`val`] -- Instance
	SerializedTable[`24`].Parent=SerializedTable[`val`] -- Instance
	SerializedTable[`25`].Parent=SerializedTable[`val`] -- Instance
	SerializedTable[`26`].Parent=SerializedTable[`val`] -- Instance
	SerializedTable[`27`].Parent=SerializedTable[`val`] -- Instance
	SerializedTable[`28`].Parent=SerializedTable[`val`] -- Instance
	SerializedTable[`29`].Parent=SerializedTable[`val`] -- Instance
	SerializedTable[`Part`].Parent=SerializedTable[`Workspace`] -- Instance
	SerializedTable[`Part`].BottomSurface=Enum.SurfaceType.Smooth -- EnumItem
	SerializedTable[`Part`].TopSurface=Enum.SurfaceType.Smooth -- EnumItem
	SerializedTable[`31`].Parent=SerializedTable[`Workspace`] -- Instance
	SerializedTable[`31`].BottomSurface=Enum.SurfaceType.Smooth -- EnumItem
	SerializedTable[`31`].TopSurface=Enum.SurfaceType.Smooth -- EnumItem
	SerializedTable[`32`].Parent=SerializedTable[`Workspace`] -- Instance
	SerializedTable[`32`].BottomSurface=Enum.SurfaceType.Smooth -- EnumItem
	SerializedTable[`32`].TopSurface=Enum.SurfaceType.Smooth -- EnumItem
	SerializedTable[`33`].Parent=SerializedTable[`Workspace`] -- Instance
	SerializedTable[`33`].BottomSurface=Enum.SurfaceType.Smooth -- EnumItem
	SerializedTable[`33`].TopSurface=Enum.SurfaceType.Smooth -- EnumItem
	SerializedTable[`34`].Parent=SerializedTable[`Workspace`] -- Instance
	SerializedTable[`34`].BottomSurface=Enum.SurfaceType.Smooth -- EnumItem
	SerializedTable[`34`].TopSurface=Enum.SurfaceType.Smooth -- EnumItem
	SerializedTable[`35`].Parent=SerializedTable[`Workspace`] -- Instance
	SerializedTable[`35`].BottomSurface=Enum.SurfaceType.Smooth -- EnumItem
	SerializedTable[`35`].TopSurface=Enum.SurfaceType.Smooth -- EnumItem
	SerializedTable[`36`].Parent=SerializedTable[`Workspace`] -- Instance
	SerializedTable[`36`].BottomSurface=Enum.SurfaceType.Smooth -- EnumItem
	SerializedTable[`36`].TopSurface=Enum.SurfaceType.Smooth -- EnumItem
	SerializedTable[`37`].Parent=SerializedTable[`Workspace`] -- Instance
	SerializedTable[`37`].BottomSurface=Enum.SurfaceType.Smooth -- EnumItem
	SerializedTable[`37`].TopSurface=Enum.SurfaceType.Smooth -- EnumItem
	SerializedTable[`38`].Parent=SerializedTable[`Workspace`] -- Instance
	SerializedTable[`38`].BottomSurface=Enum.SurfaceType.Smooth -- EnumItem
	SerializedTable[`38`].TopSurface=Enum.SurfaceType.Smooth -- EnumItem
	SerializedTable[`39`].Parent=SerializedTable[`Workspace`] -- Instance
	SerializedTable[`39`].BottomSurface=Enum.SurfaceType.Smooth -- EnumItem
	SerializedTable[`39`].TopSurface=Enum.SurfaceType.Smooth -- EnumItem
	SerializedTable[`40`].Parent=SerializedTable[`Workspace`] -- Instance
	SerializedTable[`40`].BottomSurface=Enum.SurfaceType.Smooth -- EnumItem
	SerializedTable[`40`].TopSurface=Enum.SurfaceType.Smooth -- EnumItem
	SerializedTable[`41`].Parent=SerializedTable[`Workspace`] -- Instance
	SerializedTable[`41`].BottomSurface=Enum.SurfaceType.Smooth -- EnumItem
	SerializedTable[`41`].TopSurface=Enum.SurfaceType.Smooth -- EnumItem
	SerializedTable[`42`].Parent=SerializedTable[`Workspace`] -- Instance
	SerializedTable[`42`].BottomSurface=Enum.SurfaceType.Smooth -- EnumItem
	SerializedTable[`42`].TopSurface=Enum.SurfaceType.Smooth -- EnumItem
	SerializedTable[`43`].Parent=SerializedTable[`Workspace`] -- Instance
	SerializedTable[`43`].BottomSurface=Enum.SurfaceType.Smooth -- EnumItem
	SerializedTable[`43`].TopSurface=Enum.SurfaceType.Smooth -- EnumItem
	SerializedTable[`44`].Parent=SerializedTable[`Workspace`] -- Instance
	SerializedTable[`44`].BottomSurface=Enum.SurfaceType.Smooth -- EnumItem
	SerializedTable[`44`].TopSurface=Enum.SurfaceType.Smooth -- EnumItem
	SerializedTable[`45`].Parent=SerializedTable[`Workspace`] -- Instance
	SerializedTable[`45`].BottomSurface=Enum.SurfaceType.Smooth -- EnumItem
	SerializedTable[`45`].TopSurface=Enum.SurfaceType.Smooth -- EnumItem
	SerializedTable[`46`].Parent=SerializedTable[`Workspace`] -- Instance
	SerializedTable[`46`].BottomSurface=Enum.SurfaceType.Smooth -- EnumItem
	SerializedTable[`46`].TopSurface=Enum.SurfaceType.Smooth -- EnumItem
	SerializedTable[`47`].Parent=SerializedTable[`Workspace`] -- Instance
	SerializedTable[`47`].BottomSurface=Enum.SurfaceType.Smooth -- EnumItem
	SerializedTable[`47`].TopSurface=Enum.SurfaceType.Smooth -- EnumItem
end
InsertSerial()

I was wondering if there’s a way to make this take up less lines by omptimizing properties. I already check if the property is original (which my old one didn’t, this new one has reduced by 1562 compared to 2819 lines for some scripts.)

3 Likes

Well if you have to have all those items, I wouldn’t really worry about it. Put it in a module script and access it form other places, it won’t get in your way or harm performance. Though tbf, I’ve never done this so idk if there is a better way.

1 Like
for i, child in folder:GetDescendants() do
    SerializedTable[child.Name] = child
end
3 Likes

This is something I should’ve been doing from the start considering the fact that if two instances have the same name then that means I would’ve never needed to use them anyway.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.