Right now, there is a pattern known as create that a huge number of games implement. It allows easy creation of a roblox instance, which are often heavy with properties and child objects. Normally to create a roblox instance you have to make it and then set all its properties individually, and then do that for every object in the tree.
local partWithADecal = Instance.new('Part')
partWithADecal.Name = 'PartWithADecal'
partWithADecal.Transparency = 1
partWithADecal.CFrame = CFrame.new(0, 5, 0)
partWithADecal.Anchored = true
partWithADecal.CanCollide = false
partWithADecal.CanQuery = false
partWithADecal.CanTouch = false
local decalInsideThePart = Instance.new('Decal')
decalInsideThePart.Texture = 'something'
decalInsideThePart.Face = Enum.NormalId.Bottom
decalInsideThePart.Parent = partWithADecal
partWithADecal.Parent = workspace
This is obviously annoying. Annoying to write, annoying to read, annoying to modify. The create pattern is so common because it solves all of these problems. It follows the formula create 'name' {props and children}.
partWithADecal = create 'Part' {
Name = 'PartWithADecal',
Transparency = 1,
CFrame = CFrame.new(0, 5, 0),
Anchored = true,
CanCollide = false,
CanQuery = false,
CanTouch = false,
create 'Decal' {
Texture = 'something',
Face = Enum.NormalId.Back,
}
}
partWithADecal.Parent = workspace
I want this to be a first-party api that I don’t have to import into every script in my game.
I think the ideal interface is simply calling the existing Instance library as a function.
anchoredPart = Instance 'Part' {
Anchored = true
}
Elegant and simple.