You could create a function that assigns properties to your new part. Here is an example:
local function createObject(class, parent, properties)
local obj = Instance.new(class)
for i,v in pairs(properties) do
obj[i] = v
end
obj.Parent = parent
return obj
end
local Parts = {
OnePart = createObject("Part",workspace,{CanCollide=false,Transparency=1})
}
local part = Instance.new("Part")
parte.Parent = FolderParts
parte.CanCollide = false
parte.Transparency = 1
do
local part = Instance.new("Part")
part.CanCollide = false
part.Transparency = 1
part.Parent = FolderParts -- Parent is last
Since we’re changing the way the part appears, we want to do it first before parenting into workspace. That way, it doesn’t have to re-update in workspace to change its apperance.
(the posts that they linked above explain more but heres a general summary.)
Yours:
Create part
parent part to workspace
update visual on part – default
change visual on part again.
New:
Create part
update visual on part
parent part to workspace.
Or something along the lines of that (just try reading on the PSA post.)
Make sure that if you are using this function, when you want to create an object without adding any custom properties, make sure to include an empty table. Example:
createObject("Part",game.ServerStorage,{})
EDIT: There are ways to avoid this really small inconvenience, like adding a check inside the function, but that does slow things down (very minorly).
Make sure when calling the createObject function, the first parameter is the string value of the class of the object you want to create, the second parameter is the Instance that the created object is parented to, and the third parameter is a table containing the properties that you want to add to the created object. The table must be in this format:
Ah, I know why. The part you are creating, since it’s CanCollide property is set to true, is falling to the bottom of the map and deleting. You should add the Anchored property and set it to true to stop it from falling and deleting.
Says the error is occuring on the TwoWeld. I can’t see why it’s any different than OneWeld.
But, another issue that I noticed is that since they are both part of the same table, you can’t refer to other members of the table while still inside the table. I suggest separating the tables, or even making another function that makes both the part and the weld.