Last active
February 2, 2019 07:39
-
-
Save Nimblz/56cad62f620694bfdef8fa0a00216fec to your computer and use it in GitHub Desktop.
messing around
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function new(class,propsDict,childArray) | |
propsDict = propsDict or {} | |
childArray = childArray or {} | |
local newClass = Instance.new(class) | |
-- Property time | |
for prop,val in pairs(propsDict) do | |
if prop ~= "Parent" then | |
newClass[prop] = val | |
end | |
end | |
-- Grab the child | |
for _,child in pairs(childArray) do | |
child.Parent = newClass | |
end | |
if propsDict.Parent then | |
newClass.Parent = propsDict.Parent | |
end | |
return newClass | |
end | |
new( | |
"Part", -- ClassName | |
{ -- Props | |
Name = "Root Block", | |
CFrame = CFrame.new(0,100,0), | |
Size = Vector3.new(30,30,30), | |
Material = Enum.Material.Neon, | |
Color = Color3.fromRGB(255,150,0), | |
Anchored = true, | |
CanCollide = false, | |
-- Parent is set last after all other props and after creating and parenting all children. | |
Parent = game:GetService("Workspace"), | |
}, | |
{ -- Children | |
new("WedgePart", | |
{ | |
Name = "Child Wedge", | |
CFrame = CFrame.new(0,100,40), | |
Size = Vector3.new(30,30,30), | |
Material = Enum.Material.Neon, | |
Color = Color3.fromRGB(0,150,255), | |
Anchored = true, | |
CanCollide = false, | |
} | |
), | |
new("Part", | |
{ | |
Name = "Child Ball", | |
CFrame = CFrame.new(0,100,80), | |
Size = Vector3.new(30,30,30), | |
Material = Enum.Material.Neon, | |
Color = Color3.fromRGB(0,255,0), | |
Shape = Enum.PartType.Ball, | |
Anchored = true, | |
CanCollide = false, | |
-- This will be overwritten by it being a child. | |
Parent = game:GetService("Workspace") | |
} | |
), | |
} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment