You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
I want to make a plugin that turns parts into modulescript
- What is the issue? Include screenshots / videos if possible!
It works, but the size, position, and color are all set to “Null”
local toolbar = plugin:CreateToolbar("Part to Module script")
local newscriptbutton = toolbar:CreateButton("Convert Parts to Modules", "Convert Parts to Modules", "rbxassetid://1")
local Selection = game:GetService("Selection")
local Data = {}
newscriptbutton.Click:Connect(function()
local newmodule = Instance.new("ModuleScript")
for i,v in pairs(Selection:Get()) do
if v:IsA("Model") then
for x,part in pairs(v:GetDescendants()) do
if part:IsA("Part") then
local rand = math.random(1,100000)
Data[part.Name.. tostring(rand)] = {}
Data[part.Name.. tostring(rand)]["CFrame"] = part.CFrame
Data[part.Name.. tostring(rand)]["Color"] = part.Color
Data[part.Name.. tostring(rand)]["Size"] = part.Size
Data[part.Name.. tostring(rand)]["PositionOffset"] = workspace.OriginPart.Position - part.Position
end
end
else
if v:IsA("Part") then
local part = v
local rand = math.random(1,100000)
Data[part.Name.. tostring(rand)] = {}
Data[part.Name.. tostring(rand)]["CFrame"] = part.CFrame
Data[part.Name.. tostring(rand)]["Color"] = part.Color3
Data[part.Name.. tostring(rand)]["Size"] = part.Size
Data[part.Name.. tostring(rand)]["PositionOffset"] = workspace.OriginPart.Position - part.Position
end
end
end
newmodule.Parent = game.Workspace
newmodule.Source = "local module = ".. tostring(game:GetService('HttpService'):JSONEncode(Data)).. ' return module'
end)