Roblox Basics
Roblox Programming (PDF) (
./documents/RobloxProgramming3.pdf )
Roblox Programming (PDF SlideShow).
Creating the Generic Shapes Module
Add a module to ReplicatedStorage. Rename the module: "genericShapes"
This module will contain the basic methods for drawing shapes such as squares, circles, cubes, spheres, panels, rectangles, discs, etc. As a module, it will be initially created with the default beginning and ending lines (see below).
Example: local module = {}
return module
Change the class from "module" to "shapes"
Example: local shapes = {}
return shapes
Add two comments to the beginning of the module to help document its location and purpose. Your code should now look like:
Example: --ReplicatedStorage.genericShapes (module)
--This module will be used to create generic shapes
local shapes = {}
return shapes
Add a method (for testing and debugging purposes) to this module. This method will be called: .helloWorld()
Example: --ReplicatedStorage.genericShapes (module)
--This module will be used to create generic shapes
local shapes = {}
--This function returns a string value
function shapes.helloWorld()
return "Hello World"
end
return shapes
Edit the BaseplateScript
The BaseplateScript will be executed when the Baseplate is drawn on the screen.
Example: --baseplateScript
local ServerStorage = game:GetService("ReplicatedStorage")
local s = require(ReplicatedStorage.genericShapes)
In the code above, the variable
s is being assigned the module genericShapes.
Example: --baseplateScript
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local s = require(ReplicatedStorage.genericShapes)
print(s.helloWorld())
Now run the program and examine the output.
Edit the genericShapes Module to add shape methods
The genericShapes module will contain dozens of methods for creating and manipulating shapes. You will add the method below to the genericShapes module.
Example: --This function creates a cube
function shapes.cube(size)
local mainPart = Instance.new("Part")
mainPart.Anchored = true
mainPart.Shape = Enum.PartType.Block
mainPart.TopSurface = Enum.SurfaceType.Smooth
mainPart.BottomSurface = Enum.SurfaceType.Smooth
mainPart.Transparency = 0
mainPart.Reflectance = 0.6
mainPart.Parent = workspace
mainPart.Size = Vector3.new(size,size,size)
local zCoord = -15
local xCoord = 0
mainPart.Position = mainPart.Position + Vector3.new(xCoord,size/2,zCoord)
return mainPart
end
Your genericShapes module should now look like:
Example: --ReplicatedStorage.genericShapes (module)
--This module will be used to create generic shapes
local shapes = {}
--This function returns a string value
function shapes.helloWorld()
return "Hello World"
end
--This function creates a cube
function shapes.cube(size)
local mainPart = Instance.new("Part")
mainPart.Anchored = true
mainPart.Shape = Enum.PartType.Block
mainPart.TopSurface = Enum.SurfaceType.Smooth
mainPart.BottomSurface = Enum.SurfaceType.Smooth
mainPart.Transparency = 0
mainPart.Reflectance = 0.6
mainPart.Parent = workspace
mainPart.Size = Vector3.new(size,size,size)
local zCoord = -15
local xCoord = 0
mainPart.Position = mainPart.Position + Vector3.new(xCoord,size/2,zCoord)
return mainPart
end
return shapes
Edit the baseplateScript to create this new shape
Example: --baseplateScript
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local s = require(ReplicatedStorage.genericShapes)
--print(s.helloWorld())
local mainPart = s.cube(10)
Run your program...
Creating a .fill() Method
This method will be created over a few steps and after some debugging
Start by adding the method below
Example: --This function changes the color of the object
function shapes.fill(mainPart, colorValue)
mainPart.Color = colorValue
end
Your genericShapes module should look like:
Example: --ReplicatedStorage.genericShapes (module)
--This module will be used to create generic shapes
local shapes = {}
--This function returns a string value
function shapes.helloWorld()
return "Hello World"
end
--This function creates a cube
function shapes.cube(size)
local mainPart = Instance.new("Part")
mainPart.Anchored = true
mainPart.Shape = Enum.PartType.Block
mainPart.TopSurface = Enum.SurfaceType.Smooth
mainPart.BottomSurface = Enum.SurfaceType.Smooth
mainPart.Transparency = 0
mainPart.Reflectance = 0.6
mainPart.Parent = workspace
mainPart.Size = Vector3.new(size,size,size)
local zCoord = -15
local xCoord = 0
mainPart.Position = mainPart.Position + Vector3.new(xCoord,size/2,zCoord)
return mainPart
end
--This function changes the color of the object
function shapes. Fill(mainPart, colorValue)
mainPart.Color = colorValue
end
return shapes
Test the genericShapes .fill() method by editing the baseplateScript
Add the .fill() method to the mainPart object. This is shown as the last line below. Your baseplateScript should look like the example below.
Example: --baseplateScript
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local s = require(ReplicatedStorage.genericShapes)
--print(s.helloWorld())
local mainPart = s.cube(10)
mainPart = s.fill(mainPart, Color3.new(1, 0, 1))
Run it...
Add additional capabilities to the .fill() method
We will add the ability to pass a string (colorName) to the method.
Example: --ReplicatedStorage.genericShapes (module)
--This module will be used to create generic shapes
local shapes = {}
--This function returns a string value
function shapes.helloWorld()
return "Hello World"
end
--This function creates a cube
function shapes.cube(size)
local mainPart = Instance.new("Part")
mainPart.Anchored = true
mainPart.Shape = Enum.PartType.Block
mainPart.TopSurface = Enum.SurfaceType.Smooth
mainPart.BottomSurface = Enum.SurfaceType.Smooth
mainPart.Transparency = 0
mainPart.Reflectance = 0.6
mainPart.Parent = workspace
mainPart.Size = Vector3.new(size,size,size)
local zCoord = -15
local xCoord = 0
mainPart.Position = mainPart.Position + Vector3.new(xCoord,size/2,zCoord)
return mainPart
end
--This function changes the color of the object
function shapes.fill(mainPart, colorValue)
if typeof(colorValue) == "Color3" then
mainPart.Color = colorValue
else
if typeof(colorValue) == "string" then
mainPart.Color = Color3.new(1, 0, 0)
else
print("Error in the Fill method. You need to pass a Color3 vector or a string")
end
end
return mainPart
end
return shapes
Currently with the example above, if a string is passed, the color will be set to:
Color3.new(1, 0, 0) which is the color "red". We will now test this by updating the
baseplateScript to pass a string.
Example: --baseplateScript
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local s = require(ReplicatedStorage.genericShapes)
--print(s.helloWorld())
local mainPart = s.cube(10)
mainPart = s.fill(mainPart, "red")
Run it...
Add a colorNames Table to the genericShapes module
The color names will be added to the genericShapes module above the methods.
Example:
local colorName={
["pink"]={["RGB"]="FFC0CB", ["DEC"]={255,192,203}},
["lightpink"]={["RGB"]="FFB6C1", ["DEC"]={255,182,193}},
["hotpink"]={["RGB"]="FF69B4", ["DEC"]={255,105,180}},
["deeppink"]={["RGB"]="FF1493", ["DEC"]={255,20,147}},
["palevioletred"]={["RGB"]="DB7093", ["DEC"]={219,112,147}},
["mediumvioletred"]={["RGB"]="C71585", ["DEC"]={199,21,133}},
["lightsalmon"]={["RGB"]="FFA07A", ["DEC"]={255,160,122}},
["salmon"]={["RGB"]="FA8072", ["DEC"]={250,128,114}},
["darksalmon"]={["RGB"]="E9967A", ["DEC"]={233,150,122}},
["lightcoral"]={["RGB"]="F08080", ["DEC"]={240,128,128}},
["indianred"]={["RGB"]="CD5C5C", ["DEC"]={205,92,92}},
["crimson"]={["RGB"]="DC143C", ["DEC"]={220,20,60}},
["firebrick"]={["RGB"]="B22222", ["DEC"]={178,34,34}},
["darkred"]={["RGB"]="8B0000", ["DEC"]={139,0,0}},
["red"]={["RGB"]="FF0000", ["DEC"]={255,0,0}},
["orangered"]={["RGB"]="FF4500", ["DEC"]={255,69,0}},
["tomato"]={["RGB"]="FF6347", ["DEC"]={255,99,71}},
["coral"]={["RGB"]="FF7F50", ["DEC"]={255,127,80}},
["darkorange"]={["RGB"]="FF8C00", ["DEC"]={255,140,0}},
["orange"]={["RGB"]="FFA500", ["DEC"]={255,165,0}},
["yellow"]={["RGB"]="FFFF00", ["DEC"]={255,255,0}},
["lightyellow"]={["RGB"]="FFFFE0", ["DEC"]={255,255,224}},
["lemonchiffon"]={["RGB"]="FFFACD", ["DEC"]={255,250,205}},
["lightgoldenrodyellow"]={["RGB"]="FAFAD2", ["DEC"]={250,250,210}},
["papayawhip"]={["RGB"]="FFEFD5", ["DEC"]={255,239,213}},
["moccasin"]={["RGB"]="FFE4B5", ["DEC"]={255,228,181}},
["peachpuff"]={["RGB"]="FFDAB9", ["DEC"]={255,218,185}},
["palegoldenrod"]={["RGB"]="EEE8AA", ["DEC"]={238,232,170}},
["khaki"]={["RGB"]="F0E68C", ["DEC"]={240,230,140}},
["darkkhaki"]={["RGB"]="BDB76B", ["DEC"]={189,183,107}},
["gold"]={["RGB"]="FFD700", ["DEC"]={255,215,0}},
["cornsilk"]={["RGB"]="FFF8DC", ["DEC"]={255,248,220}},
["blanchedalmond"]={["RGB"]="FFEBCD", ["DEC"]={255,235,205}},
["bisque"]={["RGB"]="FFE4C4", ["DEC"]={255,228,196}},
["navajowhite"]={["RGB"]="FFDEAD", ["DEC"]={255,222,173}},
["wheat"]={["RGB"]="F5DEB3", ["DEC"]={245,222,179}},
["burlywood"]={["RGB"]="DEB887", ["DEC"]={222,184,135}},
["tan"]={["RGB"]="D2B48C", ["DEC"]={210,180,140}},
["rosybrown"]={["RGB"]="BC8F8F", ["DEC"]={188,143,143}},
["sandybrown"]={["RGB"]="F4A460", ["DEC"]={244,164,96}},
["goldenrod"]={["RGB"]="DAA520", ["DEC"]={218,165,32}},
["darkgoldenrod"]={["RGB"]="B8860B", ["DEC"]={184,134,11}},
["peru"]={["RGB"]="CD853F", ["DEC"]={205,133,63}},
["chocolate"]={["RGB"]="D2691E", ["DEC"]={210,105,30}},
["saddlebrown"]={["RGB"]="8B4513", ["DEC"]={139,69,19}},
["sienna"]={["RGB"]="A0522D", ["DEC"]={160,82,45}},
["brown"]={["RGB"]="A52A2A", ["DEC"]={165,42,42}},
["maroon"]={["RGB"]="800000", ["DEC"]={128,0,0}},
["darkolivegreen"]={["RGB"]="556B2F", ["DEC"]={85,107,47}},
["olive"]={["RGB"]="808000", ["DEC"]={128,128,0}},
["olivedrab"]={["RGB"]="6B8E23", ["DEC"]={107,142,35}},
["yellowgreen"]={["RGB"]="9ACD32", ["DEC"]={154,205,50}},
["limegreen"]={["RGB"]="32CD32", ["DEC"]={50,205,50}},
["lime"]={["RGB"]="00FF00", ["DEC"]={0,255,0}},
["lawngreen"]={["RGB"]="7CFC00", ["DEC"]={124,252,0}},
["chartreuse"]={["RGB"]="7FFF00", ["DEC"]={127,255,0}},
["greenyellow"]={["RGB"]="ADFF2F", ["DEC"]={173,255,47}},
["springgreen"]={["RGB"]="00FF7F", ["DEC"]={0,255,127}},
["mediumspringgreen"]={["RGB"]="00FA9A", ["DEC"]={0,250,154}},
["lightgreen"]={["RGB"]="90EE90", ["DEC"]={144,238,144}},
["palegreen"]={["RGB"]="98FB98", ["DEC"]={152,251,152}},
["darkseagreen"]={["RGB"]="8FBC8F", ["DEC"]={143,188,143}},
["mediumaquamarine"]={["RGB"]="66CDAA", ["DEC"]={102,205,170}},
["mediumseagreen"]={["RGB"]="3CB371", ["DEC"]={60,179,113}},
["seagreen"]={["RGB"]="2E8B57", ["DEC"]={46,139,87}},
["forestgreen"]={["RGB"]="228B22", ["DEC"]={34,139,34}},
["green"]={["RGB"]="008000", ["DEC"]={0,128,0}},
["darkgreen"]={["RGB"]="006400", ["DEC"]={0,100,0}},
["aqua"]={["RGB"]="00FFFF", ["DEC"]={0,255,255}},
["cyan"]={["RGB"]="00FFFF", ["DEC"]={0,255,255}},
["lightcyan"]={["RGB"]="E0FFFF", ["DEC"]={224,255,255}},
["paleturquoise"]={["RGB"]="AFEEEE", ["DEC"]={175,238,238}},
["aquamarine"]={["RGB"]="7FFFD4", ["DEC"]={127,255,212}},
["turquoise"]={["RGB"]="40E0D0", ["DEC"]={64,224,208}},
["mediumturquoise"]={["RGB"]="48D1CC", ["DEC"]={72,209,204}},
["darkturquoise"]={["RGB"]="00CED1", ["DEC"]={0,206,209}},
["lightseagreen"]={["RGB"]="20B2AA", ["DEC"]={32,178,170}},
["cadetblue"]={["RGB"]="5F9EA0", ["DEC"]={95,158,160}},
["darkcyan"]={["RGB"]="008B8B", ["DEC"]={0,139,139}},
["teal"]={["RGB"]="008080", ["DEC"]={0,128,128}},
["lightsteelblue"]={["RGB"]="B0C4DE", ["DEC"]={176,196,222}},
["powderblue"]={["RGB"]="B0E0E6", ["DEC"]={176,224,230}},
["lightblue"]={["RGB"]="ADD8E6", ["DEC"]={173,216,230}},
["skyblue"]={["RGB"]="87CEEB", ["DEC"]={135,206,235}},
["lightskyblue"]={["RGB"]="87CEFA", ["DEC"]={135,206,250}},
["deepskyblue"]={["RGB"]="00BFFF", ["DEC"]={0,191,255}},
["dodgerblue"]={["RGB"]="1E90FF", ["DEC"]={30,144,255}},
["cornflowerblue"]={["RGB"]="6495ED", ["DEC"]={100,149,237}},
["steelblue"]={["RGB"]="4682B4", ["DEC"]={70,130,180}},
["royalblue"]={["RGB"]="041690", ["DEC"]={65,105,225}},
["blue"]={["RGB"]="0000FF", ["DEC"]={0,0,255}},
["mediumblue"]={["RGB"]="0000CD", ["DEC"]={0,0,205}},
["darkblue"]={["RGB"]="00008B", ["DEC"]={0,0,139}},
["navy"]={["RGB"]="000080", ["DEC"]={0,0,128}},
["midnightblue"]={["RGB"]="191970", ["DEC"]={25,25,112}},
["lavender"]={["RGB"]="E6E6FA", ["DEC"]={230,230,250}},
["thistle"]={["RGB"]="D8BFD8", ["DEC"]={216,191,216}},
["plum"]={["RGB"]="DDA0DD", ["DEC"]={221,160,221}},
["violet"]={["RGB"]="EE82EE", ["DEC"]={238,130,238}},
["orchid"]={["RGB"]="DA70D6", ["DEC"]={218,112,214}},
["fuchsia"]={["RGB"]="FF00FF", ["DEC"]={255,0,255}},
["magenta"]={["RGB"]="FF00FF", ["DEC"]={255,0,255}},
["mediumorchid"]={["RGB"]="BA55D3", ["DEC"]={186,85,211}},
["mediumpurple"]={["RGB"]="9370DB", ["DEC"]={147,112,219}},
["blueviolet"]={["RGB"]="8A2BE2", ["DEC"]={138,43,226}},
["darkviolet"]={["RGB"]="9400D3", ["DEC"]={148,0,211}},
["darkorchid"]={["RGB"]="9932CC", ["DEC"]={153,50,204}},
["darkmagenta"]={["RGB"]="8B008B", ["DEC"]={139,0,139}},
["purple"]={["RGB"]="800080", ["DEC"]={128,0,128}},
["indigo"]={["RGB"]="4B0082", ["DEC"]={75,0,130}},
["darkslateblue"]={["RGB"]="483D8B", ["DEC"]={72,61,139}},
["slateblue"]={["RGB"]="6A5ACD", ["DEC"]={106,90,205}},
["mediumslateblue"]={["RGB"]="7B68EE", ["DEC"]={123,104,238}},
["white"]={["RGB"]="FFFFFF", ["DEC"]={255,255,255}},
["snow"]={["RGB"]="FFFAFA", ["DEC"]={255,250,250}},
["honeydew"]={["RGB"]="F0FFF0", ["DEC"]={240,255,240}},
["mintcream"]={["RGB"]="F5FFFA", ["DEC"]={245,255,250}},
["azure"]={["RGB"]="F0FFFF", ["DEC"]={240,255,255}},
["aliceblue"]={["RGB"]="F0F8FF", ["DEC"]={240,248,255}},
["ghostwhite"]={["RGB"]="F8F8FF", ["DEC"]={248,248,255}},
["whitesmoke"]={["RGB"]="F5F5F5", ["DEC"]={245,245,245}},
["seashell"]={["RGB"]="FFF5EE", ["DEC"]={255,245,238}},
["beige"]={["RGB"]="F5F5DC", ["DEC"]={245,245,220}},
["oldlace"]={["RGB"]="FDF5E6", ["DEC"]={253,245,230}},
["floralwhite"]={["RGB"]="FFFAF0", ["DEC"]={255,250,240}},
["ivory"]={["RGB"]="FFFFF0", ["DEC"]={255,255,240}},
["antiquewhite"]={["RGB"]="FAEBD7", ["DEC"]={250,235,215}},
["linen"]={["RGB"]="FAF0E6", ["DEC"]={250,240,230}},
["lavenderblush"]={["RGB"]="FFF0F5", ["DEC"]={255,240,245}},
["mistyrose"]={["RGB"]="FFE4E1", ["DEC"]={255,228,225}},
["gainsboro"]={["RGB"]="DCDCDC", ["DEC"]={220,220,220}},
["lightgrey"]={["RGB"]="D3D3D3", ["DEC"]={211,211,211}},
["silver"]={["RGB"]="C0C0C0", ["DEC"]={192,192,192}},
["darkgray"]={["RGB"]="A9A9A9", ["DEC"]={169,169,169}},
["gray"]={["RGB"]="808080", ["DEC"]={128,128,128}},
["dimgray"]={["RGB"]="696969", ["DEC"]={105,105,105}},
["lightslategray"]={["RGB"]="778899", ["DEC"]={119,136,153}},
["slategray"]={["RGB"]="708090", ["DEC"]={112,128,144}},
["darkslategray"]={["RGB"]="2F4F4F", ["DEC"]={47,79,79}},
["black"]={["RGB"]="000000", ["DEC"]={0,0,0}}
} The complete genericShapes module should look like:
Example:
--ServerStorage.genericShapes (module)
--This module will be used to create generic shapes
local shapes = {}
local colorName={
["pink"]={["RGB"]="FFC0CB", ["DEC"]={255,192,203}},
["lightpink"]={["RGB"]="FFB6C1", ["DEC"]={255,182,193}},
["hotpink"]={["RGB"]="FF69B4", ["DEC"]={255,105,180}},
["deeppink"]={["RGB"]="FF1493", ["DEC"]={255,20,147}},
["palevioletred"]={["RGB"]="DB7093", ["DEC"]={219,112,147}},
["mediumvioletred"]={["RGB"]="C71585", ["DEC"]={199,21,133}},
["lightsalmon"]={["RGB"]="FFA07A", ["DEC"]={255,160,122}},
["salmon"]={["RGB"]="FA8072", ["DEC"]={250,128,114}},
["darksalmon"]={["RGB"]="E9967A", ["DEC"]={233,150,122}},
["lightcoral"]={["RGB"]="F08080", ["DEC"]={240,128,128}},
["indianred"]={["RGB"]="CD5C5C", ["DEC"]={205,92,92}},
["crimson"]={["RGB"]="DC143C", ["DEC"]={220,20,60}},
["firebrick"]={["RGB"]="B22222", ["DEC"]={178,34,34}},
["darkred"]={["RGB"]="8B0000", ["DEC"]={139,0,0}},
["red"]={["RGB"]="FF0000", ["DEC"]={255,0,0}},
["orangered"]={["RGB"]="FF4500", ["DEC"]={255,69,0}},
["tomato"]={["RGB"]="FF6347", ["DEC"]={255,99,71}},
["coral"]={["RGB"]="FF7F50", ["DEC"]={255,127,80}},
["darkorange"]={["RGB"]="FF8C00", ["DEC"]={255,140,0}},
["orange"]={["RGB"]="FFA500", ["DEC"]={255,165,0}},
["yellow"]={["RGB"]="FFFF00", ["DEC"]={255,255,0}},
["lightyellow"]={["RGB"]="FFFFE0", ["DEC"]={255,255,224}},
["lemonchiffon"]={["RGB"]="FFFACD", ["DEC"]={255,250,205}},
["lightgoldenrodyellow"]={["RGB"]="FAFAD2", ["DEC"]={250,250,210}},
["papayawhip"]={["RGB"]="FFEFD5", ["DEC"]={255,239,213}},
["moccasin"]={["RGB"]="FFE4B5", ["DEC"]={255,228,181}},
["peachpuff"]={["RGB"]="FFDAB9", ["DEC"]={255,218,185}},
["palegoldenrod"]={["RGB"]="EEE8AA", ["DEC"]={238,232,170}},
["khaki"]={["RGB"]="F0E68C", ["DEC"]={240,230,140}},
["darkkhaki"]={["RGB"]="BDB76B", ["DEC"]={189,183,107}},
["gold"]={["RGB"]="FFD700", ["DEC"]={255,215,0}},
["cornsilk"]={["RGB"]="FFF8DC", ["DEC"]={255,248,220}},
["blanchedalmond"]={["RGB"]="FFEBCD", ["DEC"]={255,235,205}},
["bisque"]={["RGB"]="FFE4C4", ["DEC"]={255,228,196}},
["navajowhite"]={["RGB"]="FFDEAD", ["DEC"]={255,222,173}},
["wheat"]={["RGB"]="F5DEB3", ["DEC"]={245,222,179}},
["burlywood"]={["RGB"]="DEB887", ["DEC"]={222,184,135}},
["tan"]={["RGB"]="D2B48C", ["DEC"]={210,180,140}},
["rosybrown"]={["RGB"]="BC8F8F", ["DEC"]={188,143,143}},
["sandybrown"]={["RGB"]="F4A460", ["DEC"]={244,164,96}},
["goldenrod"]={["RGB"]="DAA520", ["DEC"]={218,165,32}},
["darkgoldenrod"]={["RGB"]="B8860B", ["DEC"]={184,134,11}},
["peru"]={["RGB"]="CD853F", ["DEC"]={205,133,63}},
["chocolate"]={["RGB"]="D2691E", ["DEC"]={210,105,30}},
["saddlebrown"]={["RGB"]="8B4513", ["DEC"]={139,69,19}},
["sienna"]={["RGB"]="A0522D", ["DEC"]={160,82,45}},
["brown"]={["RGB"]="A52A2A", ["DEC"]={165,42,42}},
["maroon"]={["RGB"]="800000", ["DEC"]={128,0,0}},
["darkolivegreen"]={["RGB"]="556B2F", ["DEC"]={85,107,47}},
["olive"]={["RGB"]="808000", ["DEC"]={128,128,0}},
["olivedrab"]={["RGB"]="6B8E23", ["DEC"]={107,142,35}},
["yellowgreen"]={["RGB"]="9ACD32", ["DEC"]={154,205,50}},
["limegreen"]={["RGB"]="32CD32", ["DEC"]={50,205,50}},
["lime"]={["RGB"]="00FF00", ["DEC"]={0,255,0}},
["lawngreen"]={["RGB"]="7CFC00", ["DEC"]={124,252,0}},
["chartreuse"]={["RGB"]="7FFF00", ["DEC"]={127,255,0}},
["greenyellow"]={["RGB"]="ADFF2F", ["DEC"]={173,255,47}},
["springgreen"]={["RGB"]="00FF7F", ["DEC"]={0,255,127}},
["mediumspringgreen"]={["RGB"]="00FA9A", ["DEC"]={0,250,154}},
["lightgreen"]={["RGB"]="90EE90", ["DEC"]={144,238,144}},
["palegreen"]={["RGB"]="98FB98", ["DEC"]={152,251,152}},
["darkseagreen"]={["RGB"]="8FBC8F", ["DEC"]={143,188,143}},
["mediumaquamarine"]={["RGB"]="66CDAA", ["DEC"]={102,205,170}},
["mediumseagreen"]={["RGB"]="3CB371", ["DEC"]={60,179,113}},
["seagreen"]={["RGB"]="2E8B57", ["DEC"]={46,139,87}},
["forestgreen"]={["RGB"]="228B22", ["DEC"]={34,139,34}},
["green"]={["RGB"]="008000", ["DEC"]={0,128,0}},
["darkgreen"]={["RGB"]="006400", ["DEC"]={0,100,0}},
["aqua"]={["RGB"]="00FFFF", ["DEC"]={0,255,255}},
["cyan"]={["RGB"]="00FFFF", ["DEC"]={0,255,255}},
["lightcyan"]={["RGB"]="E0FFFF", ["DEC"]={224,255,255}},
["paleturquoise"]={["RGB"]="AFEEEE", ["DEC"]={175,238,238}},
["aquamarine"]={["RGB"]="7FFFD4", ["DEC"]={127,255,212}},
["turquoise"]={["RGB"]="40E0D0", ["DEC"]={64,224,208}},
["mediumturquoise"]={["RGB"]="48D1CC", ["DEC"]={72,209,204}},
["darkturquoise"]={["RGB"]="00CED1", ["DEC"]={0,206,209}},
["lightseagreen"]={["RGB"]="20B2AA", ["DEC"]={32,178,170}},
["cadetblue"]={["RGB"]="5F9EA0", ["DEC"]={95,158,160}},
["darkcyan"]={["RGB"]="008B8B", ["DEC"]={0,139,139}},
["teal"]={["RGB"]="008080", ["DEC"]={0,128,128}},
["lightsteelblue"]={["RGB"]="B0C4DE", ["DEC"]={176,196,222}},
["powderblue"]={["RGB"]="B0E0E6", ["DEC"]={176,224,230}},
["lightblue"]={["RGB"]="ADD8E6", ["DEC"]={173,216,230}},
["skyblue"]={["RGB"]="87CEEB", ["DEC"]={135,206,235}},
["lightskyblue"]={["RGB"]="87CEFA", ["DEC"]={135,206,250}},
["deepskyblue"]={["RGB"]="00BFFF", ["DEC"]={0,191,255}},
["dodgerblue"]={["RGB"]="1E90FF", ["DEC"]={30,144,255}},
["cornflowerblue"]={["RGB"]="6495ED", ["DEC"]={100,149,237}},
["steelblue"]={["RGB"]="4682B4", ["DEC"]={70,130,180}},
["royalblue"]={["RGB"]="041690", ["DEC"]={65,105,225}},
["blue"]={["RGB"]="0000FF", ["DEC"]={0,0,255}},
["mediumblue"]={["RGB"]="0000CD", ["DEC"]={0,0,205}},
["darkblue"]={["RGB"]="00008B", ["DEC"]={0,0,139}},
["navy"]={["RGB"]="000080", ["DEC"]={0,0,128}},
["midnightblue"]={["RGB"]="191970", ["DEC"]={25,25,112}},
["lavender"]={["RGB"]="E6E6FA", ["DEC"]={230,230,250}},
["thistle"]={["RGB"]="D8BFD8", ["DEC"]={216,191,216}},
["plum"]={["RGB"]="DDA0DD", ["DEC"]={221,160,221}},
["violet"]={["RGB"]="EE82EE", ["DEC"]={238,130,238}},
["orchid"]={["RGB"]="DA70D6", ["DEC"]={218,112,214}},
["fuchsia"]={["RGB"]="FF00FF", ["DEC"]={255,0,255}},
["magenta"]={["RGB"]="FF00FF", ["DEC"]={255,0,255}},
["mediumorchid"]={["RGB"]="BA55D3", ["DEC"]={186,85,211}},
["mediumpurple"]={["RGB"]="9370DB", ["DEC"]={147,112,219}},
["blueviolet"]={["RGB"]="8A2BE2", ["DEC"]={138,43,226}},
["darkviolet"]={["RGB"]="9400D3", ["DEC"]={148,0,211}},
["darkorchid"]={["RGB"]="9932CC", ["DEC"]={153,50,204}},
["darkmagenta"]={["RGB"]="8B008B", ["DEC"]={139,0,139}},
["purple"]={["RGB"]="800080", ["DEC"]={128,0,128}},
["indigo"]={["RGB"]="4B0082", ["DEC"]={75,0,130}},
["darkslateblue"]={["RGB"]="483D8B", ["DEC"]={72,61,139}},
["slateblue"]={["RGB"]="6A5ACD", ["DEC"]={106,90,205}},
["mediumslateblue"]={["RGB"]="7B68EE", ["DEC"]={123,104,238}},
["white"]={["RGB"]="FFFFFF", ["DEC"]={255,255,255}},
["snow"]={["RGB"]="FFFAFA", ["DEC"]={255,250,250}},
["honeydew"]={["RGB"]="F0FFF0", ["DEC"]={240,255,240}},
["mintcream"]={["RGB"]="F5FFFA", ["DEC"]={245,255,250}},
["azure"]={["RGB"]="F0FFFF", ["DEC"]={240,255,255}},
["aliceblue"]={["RGB"]="F0F8FF", ["DEC"]={240,248,255}},
["ghostwhite"]={["RGB"]="F8F8FF", ["DEC"]={248,248,255}},
["whitesmoke"]={["RGB"]="F5F5F5", ["DEC"]={245,245,245}},
["seashell"]={["RGB"]="FFF5EE", ["DEC"]={255,245,238}},
["beige"]={["RGB"]="F5F5DC", ["DEC"]={245,245,220}},
["oldlace"]={["RGB"]="FDF5E6", ["DEC"]={253,245,230}},
["floralwhite"]={["RGB"]="FFFAF0", ["DEC"]={255,250,240}},
["ivory"]={["RGB"]="FFFFF0", ["DEC"]={255,255,240}},
["antiquewhite"]={["RGB"]="FAEBD7", ["DEC"]={250,235,215}},
["linen"]={["RGB"]="FAF0E6", ["DEC"]={250,240,230}},
["lavenderblush"]={["RGB"]="FFF0F5", ["DEC"]={255,240,245}},
["mistyrose"]={["RGB"]="FFE4E1", ["DEC"]={255,228,225}},
["Gainsboro"]={["RGB"]="DCDCDC", ["DEC"]={220,220,220}},
["lightgrey"]={["RGB"]="D3D3D3", ["DEC"]={211,211,211}},
["silver"]={["RGB"]="C0C0C0", ["DEC"]={192,192,192}},
["darkgray"]={["RGB"]="A9A9A9", ["DEC"]={169,169,169}},
["gray"]={["RGB"]="808080", ["DEC"]={128,128,128}},
["dimgray"]={["RGB"]="696969", ["DEC"]={105,105,105}},
["lightslategray"]={["RGB"]="778899", ["DEC"]={119,136,153}},
["slategray"]={["RGB"]="708090", ["DEC"]={112,128,144}},
["darkslategray"]={["RGB"]="2F4F4F", ["DEC"]={47,79,79}},
["black"]={["RGB"]="000000", ["DEC"]={0,0,0}}
}
--This function returns a string value
function shapes.helloWorld()
return "Hello World"
end
--This function creates a cube
function shapes. Cube(size)
local mainPart = Instance.new("Part")
mainPart.Anchored = true
mainPart.Shape = Enum.PartType.Block
mainPart.TopSurface = Enum.SurfaceType.Smooth
mainPart.BottomSurface = Enum.SurfaceType.Smooth
mainPart.Transparency = 0
mainPart.Reflectance = 0.6
mainPart.Parent = workspace
mainPart.Size = Vector3.new(size,size,size)
local zCoord = -15
local xCoord = 0
mainPart.Position = mainPart.Position + Vector3.new(xCoord,size/2,zCoord)
return mainPart
end
--This function changes the color of the object
function shapes.fill(mainPart, colorValue)
if typeof(colorValue) == "Color3" then
mainPart.Color = colorValue
else
if typeof(colorValue) == "string" then
local red = colorName[colorValue]["DEC"][1]/255 --rescale from 0-255 to 0-1
local green = colorName[colorValue]["DEC"][2]/255 --rescale from 0-255 to 0-1
local blue = colorName[colorValue]["DEC"][3]/255 --rescale from 0-255 to 0-1
mainPart.Color = Color3.new(red, green, blue)
else
print("Error in the Fill method. You need to pass a Color3 vector or a string")
end
end
return mainPart
end
return shapes Notice that in the above code, the .fill() method has been modified to better handle the cases where a string has been passed as the color. These changes include the code below:
Example: local red = colorName[colorValue]["DEC"][1]/255 --rescale from 0-255 to 0-1
local green = colorName[colorValue]["DEC"][2]/255 --rescale from 0-255 to 0-1
local blue = colorName[colorValue]["DEC"][3]/255 --rescale from 0-255 to 0-1
mainPart.Color = Color3.new(red, green, blue)
You can test the new code by modifying the baseplateScript as shown below:
Example: --baseplateScript
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local s = require(ReplicatedStorage.genericShapes)
--print(s.helloWorld())
local mainPart = s.cube(10)
mainPart = s.fill(mainPart, "darkslateblue")
Add additional methods
Reflectance
Example: --This function changes the reflectance of the object
function shapes.reflectance(mainPart, value)
if typeof(value) == "number" then
mainPart.Reflectance = value
else
print("Error in the Reflectance method. You need to pass a number. You passed a: "..typeof(value))
end
return mainPart
end
Size
Example: --This function changes the size of the object
function shapes.size(mainPart, sizeValue)
if typeof(sizeValue) == "Vector3" then
mainPart.Size = sizeValue
else
print("Error in the Size method. You need to pass a Vector3. You passed a: "..typeof(sizeValue))
end
return mainPart
end
Rotate
Example: --This function changes the rotation of the object
function shapes.rotate(mainPart, rotateValue)
if typeof(rotateValue) == "Vector3" then
mainPart.Orientation = rotateValue
else
print("Error in the Rotation method. You need to pass a Vector3. You passed a: "..typeof(rotateValue))
end
return mainPart
end
Modify the baseplateScript to see the recent changes
Example: --baseplateScript
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local s = require(ReplicatedStorage.genericShapes)
--print(s.helloWorld())
local mainPart = s.cube(10)
mainPart = s.fill(mainPart, "darkslateblue")
s.reflectance(mainPart, 0)
Run it...
Example: --baseplateScript
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local s = require(ReplicatedStorage.genericShapes)
--print(s.helloWorld())
local mainPart = s.cube(10)
mainPart = s.fill(mainPart, "darkslateblue")
s.reflectance(mainPart, 0)
s.rotate(mainPart, Vector3.new(45, 45, 0))
Run it...
Example: --baseplateScript
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local s = require(ReplicatedStorage.genericShapes)
--print(s.helloWorld())
local mainPart = s.cube(10)
mainPart = s.fill(mainPart, "darkslateblue")
s.reflectance(mainPart, 0)
s.rotate(mainPart, Vector3.new(45, 45, 0))
s.transparency(mainPart, 0.4)
Run it...
Materials
Add the following array to the genericShapes module. Add this array right after the colorNames table.
Example: local materialNames = {
"Plastic",
"Wood",
"Slate",
"Concrete",
"CorrodedMetal",
"DiamondPlate",
"Foil",
"Grass",
"Ice",
"Marble",
"Granite",
"Brick",
"Pebble",
"Sand",
"Fabric",
"SmoothPlastic",
"Metal",
"WoodPlanks",
"Cobblestone",
"Air",
"Water",
"Rock",
"Glacier",
"Snow",
"Sandstone",
"Mud",
"Basalt",
"Ground",
"CrackedLava",
"Neon",
"Glass",
"Asphalt",
"LeafyGrass",
"Salt",
"Limestone",
"Pavement",
"ForceField"
}
Also add a .material() method toward the bottom of the script.
Example: --This function changes the material of the object
function shapes.material(mainPart, value)
--local Materials = Enum.Material:GetEnumItems()
if typeof(value) == "string" or typeof(value) == "EnumItem" then
mainPart.Material = value
else
print("Error in the Material method. You need to pass a string. You passed a: "..typeof(value))
end
return mainPart
end
Now add a material to the mainPart in the baseplateScript.
Example: --baseplateScript
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local s = require(ReplicatedStorage.genericShapes)
--print(s.helloWorld())
local mainPart = s.cube(10)
mainPart = s.fill(mainPart, "darkslateblue")
s.reflectance(mainPart, 0)
s.rotate(mainPart, Vector3.new(45, 45, 0))
s.transparency(mainPart, 0.4)
s.material(mainPart, Enum.Material.Foil)
In the example above, the material was added as an Enumerated value. In this case, Enumerated Material names Foil which was shown as: Enum.Material.Foil
Other Useful Shapes
Panel
Add the following method to the genericShapes module. Add this after the .cube() method.
Example: --This function creates a panel
function shapes.panel(size, thickness)
if typeof(thickness) == "nil" then
thickness = 0.1
end
local mainPart = Instance.new("Part")
mainPart.Anchored = true
mainPart.Shape = Enum.PartType.Block
mainPart.TopSurface = Enum.SurfaceType.Smooth
mainPart.BottomSurface = Enum.SurfaceType.Smooth
mainPart.Transparency = 0
mainPart.Reflectance = 0.6
mainPart.Parent = workspace
mainPart.Size = Vector3.new(size,thickness,size)
local zCoord = -15
local xCoord = 0
mainPart.Position = mainPart.Position + Vector3.new(xCoord,size/2,zCoord)
return mainPart
end
Square
Example: --This function creates a square
function shapes.square(size, thickness)
if typeof(thickness) == "nil" then
thickness = 0.1
end
local panel = Instance.new("Part")
panel.Anchored = true
panel.Shape = Enum.PartType.Block
panel.TopSurface = Enum.SurfaceType.Smooth
panel.BottomSurface = Enum.SurfaceType.Smooth
panel.Transparency = 0
panel.Reflectance = 0.6
panel.Parent = workspace
panel.Size = Vector3.new(size,thickness,size)
local zCoord = -15
local xCoord = 0
panel.Position = panel.Position + Vector3.new(xCoord,size/2,zCoord)
local panelN = Instance.new("Part")
panelN.Anchored = true
panelN.Shape = Enum.PartType.Block
panelN.TopSurface = Enum.SurfaceType.Smooth
panelN.BottomSurface = Enum.SurfaceType.Smooth
panelN.Transparency = 0
panelN.Reflectance = 0.6
panelN.Parent = workspace
panelN.Size = Vector3.new(size-thickness,1,size-thickness)
local zCoord = -15
local xCoord = 0
panelN.Position = panelN.Position + Vector3.new(xCoord,size/2,zCoord)
local otherParts = {panelN}
-- Perform subtract operation
local success, newSquare = pcall(function()
return panel:SubtractAsync(otherParts)
end)
-- If operation succeeds, position it at the same location and parent it to the workspace
if success and newSquare then
newSquare.Position = panel.Position
newSquare.Parent = workspace
end
-- Destroy original parts which remain intact after operation
panel:Destroy()
for i = 1, #otherParts do
otherParts[i]:Destroy()
end
newSquare.Orientation = Vector3.new(90, 0, 0)
return newSquare
end
Disc
Example: --This function creates a disc
function shapes.disc(size, thickness)
if typeof(thickness) == "nil" then
thickness = 0.1
end
local mainPart = Instance.new("Part")
mainPart.Anchored = true
mainPart.Shape = Enum.PartType.Cylinder
mainPart.TopSurface = Enum.SurfaceType.Smooth
mainPart.BottomSurface = Enum.SurfaceType.Smooth
mainPart.Transparency = 0
mainPart.Reflectance = 0.6
mainPart.Parent = workspace
mainPart.Size = Vector3.new(size,thickness,size)
local zCoord = -15
local xCoord = 0
mainPart.Position = mainPart.Position + Vector3.new(xCoord,size/2,zCoord)
return mainPart
end
Circle
Example: --This function creates a circle
function shapes.circle(size, thickness)
if typeof(thickness) == "nil" then
thickness = 0.1
end
local disc = Instance.new("Part")
disc.Anchored = true
disc.Shape = Enum.PartType.Cylinder
disc.TopSurface = Enum.SurfaceType.Smooth
disc.BottomSurface = Enum.SurfaceType.Smooth
disc.Transparency = 0
disc.Reflectance = 0.6
disc.Parent = workspace
disc.Size = Vector3.new(thickness,size,size)
disc.Orientation = Vector3.new(0, 90, 0)
local zCoord = -15
local xCoord = 0
disc.Position = disc.Position + Vector3.new(xCoord,size/2,zCoord)
local discN = Instance.new("Part")
discN.Anchored = true
discN.Shape = Enum.PartType.Cylinder
discN.TopSurface = Enum.SurfaceType.Smooth
discN.BottomSurface = Enum.SurfaceType.Smooth
discN.Transparency = 0
discN.Reflectance = 0.6
discN.Parent = workspace
discN.Size = Vector3.new(thickness+2,size-thickness,size-thickness)
discN.Orientation = Vector3.new(0, 90, 0)
local zCoord = -15
local xCoord = 0
discN.Position = discN.Position + Vector3.new(xCoord,size/2,zCoord)
local otherParts = {discN}
-- Perform subtract operation
local success, newCircle = pcall(function()
return disc:SubtractAsync(otherParts)
end)
-- If operation succeeds, position it at the same location and parent it to the workspace
if success and newCircle then
newCircle.Position = disc.Position
newCircle.Parent = workspace
end
-- Destroy original parts which remain intact after operation
disc:Destroy()
for i = 1, #otherParts do
otherParts[i]:Destroy()
end
return newCircle
end
Subtraction
Example: --This will subtract part B from part A
function shapes.subtract(mainPart, subPart)
local success, newMainPart = pcall(function()
return mainPart:SubtractAsync({subPart})
end)
-- If operation succeeds, position it at the same location and parent it to the workspace
if success and newMainPart then
newMainPart.Position = mainPart.Position
newMainPart.Parent = workspace
end
-- Destroy original parts which remain intact after operation
mainPart:Destroy()
subPart:Destroy()
return newMainPart
end
Complete genericShapes module
Example:
--[[
Location of this file: ReplicatedStorage.genericShapes (module)
This module will be used to create generic shapes
Installation: Create a ModuleScript in the ReplicatedStorage folder. Name the script: genericShapes
The functions shown below allow for a variety of methods for creating objects. Each function will have multiple
options for arguments passed into the function. All of the shape functions will take from zero to some number of arguments.
Example Usage:
*********************************
** 2D Shapes:
local s1 = s.square() -- create a default square
local s1 = s.square(5) -- create a square with sides of length 5 at the default location
local s1 = s.square(5, 0.4) -- create a square with sides of 5 and a thickness of 0.4 at the default location
local s1 = s.square(-10, 6, -15) -- create a square at the location of x=-10, y=6, z=-15
local s1 = s.square(0, 5, -15, 10) -- create a square at the location of 0,5,-15 with the size of 10
local s1 = s.square(0, 5, -15, 10, 0.5) -- create a square at the location of 0,5,-15 with the size of 10 and thickness of 0.5
local s1 = s.square(0, 5, -15, 10, 0.5) -- create a square at the location of 0,5,-15 with the size of 10 and thickness of 0.5
local s1 = s.square(0, 5, -15, 10, 0.5, Color3.new(1, 1, 0)) -- create a square ... with the color specified as a Color3 object
local s1 = s.square(0, 5, -15, 10, 0.5, "red") -- create a square ... with the color specified as a string
local s1 = s.circle() -- create a default circle
local s1 = s.circle(5) -- create a circle with diameter of length 5 at the default location
local s1 = s.circle(5, 0.4) -- create a circle with diameter of 5 and a thickness of 0.4 at the default location
local s1 = s.circle(-10, 6, -15) -- create a circle at the location of x=-10, y=6, z=-15
local s1 = s.circle(0, 5, -15, 10) -- create a circle at the location of 0,5,-15 with the size of 10
local s1 = s.circle(0, 5, -15, 10, 0.5) -- create a circle at the location of 0,5,-15 with the size of 10 and thickness of 0.5
local s1 = s.circle(0, 5, -15, 10, 0.5) -- create a circle at the location of 0,5,-15 with the size of 10 and thickness of 0.5
local s1 = s.circle(0, 5, -15, 10, 0.5, Color3.new(1, 1, 0)) -- create a circle ... with the color specified as a Color3 object
local s1 = s.circle(0, 5, -15, 10, 0.5, "red") -- create a circle ... with the color specified as a string
local s1 = s.disc() -- create a default disc
local s1 = s.disc(5) -- create a disc with diameter of length 5 at the default location
local s1 = s.disc(5, 0.4) -- create a disc with diameter of 5 and a thickness of 0.4 at the default location
local s1 = s.disc(-10, 6, -15) -- create a disc at the location of x=-10, y=6, z=-15
local s1 = s.disc(0, 5, -15, 10) -- create a disc at the location of 0,5,-15 with the size of 10
local s1 = s.disc(0, 5, -15, 10, 0.5) -- create a disc at the location of 0,5,-15 with the size of 10 and thickness of 0.5
local s1 = s.disc(0, 5, -15, 10, 0.5, Color3.new(1, 1, 0)) -- create a disc ... with the color specified as a Color3 object
local s1 = s.disc(0, 5, -15, 10, 0.5, "red") -- create a disc ... with the color specified as a string
local s1 = s.disc(0, 5, -15, 10, 0.5, "red", Enum.Material.Foil) -- create a disc ... with the Material specified as an Enum
local s1 = s.panel() -- create a default panel
local s1 = s.panel(5) -- create a panel with sides of length 5 at the default location
local s1 = s.panel(5, 0.4) -- create a panel with sides of 5 and a thickness of 0.4 at the default location
local s1 = s.panel(-10, 6, -15) -- create a panel at the location of x=-10, y=6, z=-15
local s1 = s.panel(0, 5, -15, 10) -- create a panel at the location of 0,5,-15 with the size of 10
local s1 = s.panel(0, 5, -15, 10, 0.5) -- create a panel at the location of 0,5,-15 with the size of 10 and thickness of 0.5
local s1 = s.panel(0, 5, -15, 10, 0.5) -- create a panel at the location of 0,5,-15 with the size of 10 and thickness of 0.5
local s1 = s.panel(0, 5, -15, 10, 0.5, Color3.new(1, 1, 0)) -- create a panel ... with the color specified as a Color3 object
local s1 = s.panel(0, 5, -15, 10, 0.5, "red") -- create a panel ... with the color specified as a string
local s1 = s.panel(0, 5, -15, 10, 0.5, "red", Enum.Material.Foil) -- create a panel ... with a foil material
*********************************
** 3D Shapes:
local s1 = s.cube() -- create a default cube
local s1 = s.cube(5) -- create a cube with sides of length 5 at the default location
local s1 = s.cube(5, 0.4) -- create a cube with sides of 5 and a thickness of 0.4 at the default location
local s1 = s.cube(-10, 6, -15) -- create a cube at the location of x=-10, y=6, z=-15
local s1 = s.cube(0, 5, -15, 7) -- create a cube at the location of 0,5,-15 with the size of 7
local s1 = s.cube(0, 5, -15, 7, Color3.new(1, 1, 0)) -- create a cube ... with the color specified as a Color3 object
local s1 = s.cube(0, 5, -15, 7, "red") -- create a cube ... with the color specified as a string
local s1 = s.cube(0, 5, -15, 7, "red", Enum.Material.Foil) -- create a cube ... with a foil material
local s1 = s.sphere() -- create a default sphere
local s1 = s.sphere(5) -- create a sphere with sides of length 5 at the default location
local s1 = s.sphere(5, 0.4) -- create a sphere with sides of 5 and a thickness of 0.4 at the default location
local s1 = s.sphere(-10, 6, -15) -- create a sphere at the location of x=-10, y=6, z=-15
local s1 = s.sphere(0, 5, -15, 7) -- create a sphere at the location of 0,5,-15 with the size of 7
local s1 = s.sphere(0, 5, -15, 7, Color3.new(1, 1, 0)) -- create a sphere ... with the color specified as a Color3 object
local s1 = s.sphere(0, 5, -15, 7, "red") -- create a sphere ... with the color specified as a string
local s1 = s.sphere(0, 5, -15, 7, Color3.new(0.631373, 0.52549, 0.407843),Enum.Material.Wood) -- create a sphere ... with a wood material
]]
local shapes = {}
local defaultColor = Color3.new(0.0117647, 0.984314, 1)
local defaultBorderThickness = 0.5
local colorName={
["pink"]={["RGB"]="FFC0CB", ["DEC"]={255,192,203}},
["lightpink"]={["RGB"]="FFB6C1", ["DEC"]={255,182,193}},
["hotpink"]={["RGB"]="FF69B4", ["DEC"]={255,105,180}},
["deeppink"]={["RGB"]="FF1493", ["DEC"]={255,20,147}},
["palevioletred"]={["RGB"]="DB7093", ["DEC"]={219,112,147}},
["mediumvioletred"]={["RGB"]="C71585", ["DEC"]={199,21,133}},
["lightsalmon"]={["RGB"]="FFA07A", ["DEC"]={255,160,122}},
["salmon"]={["RGB"]="FA8072", ["DEC"]={250,128,114}},
["darksalmon"]={["RGB"]="E9967A", ["DEC"]={233,150,122}},
["lightcoral"]={["RGB"]="F08080", ["DEC"]={240,128,128}},
["indianred"]={["RGB"]="CD5C5C", ["DEC"]={205,92,92}},
["crimson"]={["RGB"]="DC143C", ["DEC"]={220,20,60}},
["firebrick"]={["RGB"]="B22222", ["DEC"]={178,34,34}},
["darkred"]={["RGB"]="8B0000", ["DEC"]={139,0,0}},
["red"]={["RGB"]="FF0000", ["DEC"]={255,0,0}},
["orangered"]={["RGB"]="FF4500", ["DEC"]={255,69,0}},
["tomato"]={["RGB"]="FF6347", ["DEC"]={255,99,71}},
["coral"]={["RGB"]="FF7F50", ["DEC"]={255,127,80}},
["darkorange"]={["RGB"]="FF8C00", ["DEC"]={255,140,0}},
["orange"]={["RGB"]="FFA500", ["DEC"]={255,165,0}},
["yellow"]={["RGB"]="FFFF00", ["DEC"]={255,255,0}},
["lightyellow"]={["RGB"]="FFFFE0", ["DEC"]={255,255,224}},
["lemonchiffon"]={["RGB"]="FFFACD", ["DEC"]={255,250,205}},
["lightgoldenrodyellow"]={["RGB"]="FAFAD2", ["DEC"]={250,250,210}},
["papayawhip"]={["RGB"]="FFEFD5", ["DEC"]={255,239,213}},
["moccasin"]={["RGB"]="FFE4B5", ["DEC"]={255,228,181}},
["peachpuff"]={["RGB"]="FFDAB9", ["DEC"]={255,218,185}},
["palegoldenrod"]={["RGB"]="EEE8AA", ["DEC"]={238,232,170}},
["khaki"]={["RGB"]="F0E68C", ["DEC"]={240,230,140}},
["darkkhaki"]={["RGB"]="BDB76B", ["DEC"]={189,183,107}},
["gold"]={["RGB"]="FFD700", ["DEC"]={255,215,0}},
["cornsilk"]={["RGB"]="FFF8DC", ["DEC"]={255,248,220}},
["blanchedalmond"]={["RGB"]="FFEBCD", ["DEC"]={255,235,205}},
["bisque"]={["RGB"]="FFE4C4", ["DEC"]={255,228,196}},
["navajowhite"]={["RGB"]="FFDEAD", ["DEC"]={255,222,173}},
["wheat"]={["RGB"]="F5DEB3", ["DEC"]={245,222,179}},
["burlywood"]={["RGB"]="DEB887", ["DEC"]={222,184,135}},
["tan"]={["RGB"]="D2B48C", ["DEC"]={210,180,140}},
["rosybrown"]={["RGB"]="BC8F8F", ["DEC"]={188,143,143}},
["sandybrown"]={["RGB"]="F4A460", ["DEC"]={244,164,96}},
["goldenrod"]={["RGB"]="DAA520", ["DEC"]={218,165,32}},
["darkgoldenrod"]={["RGB"]="B8860B", ["DEC"]={184,134,11}},
["peru"]={["RGB"]="CD853F", ["DEC"]={205,133,63}},
["chocolate"]={["RGB"]="D2691E", ["DEC"]={210,105,30}},
["saddlebrown"]={["RGB"]="8B4513", ["DEC"]={139,69,19}},
["sienna"]={["RGB"]="A0522D", ["DEC"]={160,82,45}},
["brown"]={["RGB"]="A52A2A", ["DEC"]={165,42,42}},
["maroon"]={["RGB"]="800000", ["DEC"]={128,0,0}},
["darkolivegreen"]={["RGB"]="556B2F", ["DEC"]={85,107,47}},
["olive"]={["RGB"]="808000", ["DEC"]={128,128,0}},
["olivedrab"]={["RGB"]="6B8E23", ["DEC"]={107,142,35}},
["yellowgreen"]={["RGB"]="9ACD32", ["DEC"]={154,205,50}},
["limegreen"]={["RGB"]="32CD32", ["DEC"]={50,205,50}},
["lime"]={["RGB"]="00FF00", ["DEC"]={0,255,0}},
["lawngreen"]={["RGB"]="7CFC00", ["DEC"]={124,252,0}},
["chartreuse"]={["RGB"]="7FFF00", ["DEC"]={127,255,0}},
["greenyellow"]={["RGB"]="ADFF2F", ["DEC"]={173,255,47}},
["springgreen"]={["RGB"]="00FF7F", ["DEC"]={0,255,127}},
["mediumspringgreen"]={["RGB"]="00FA9A", ["DEC"]={0,250,154}},
["lightgreen"]={["RGB"]="90EE90", ["DEC"]={144,238,144}},
["palegreen"]={["RGB"]="98FB98", ["DEC"]={152,251,152}},
["darkseagreen"]={["RGB"]="8FBC8F", ["DEC"]={143,188,143}},
["mediumaquamarine"]={["RGB"]="66CDAA", ["DEC"]={102,205,170}},
["mediumseagreen"]={["RGB"]="3CB371", ["DEC"]={60,179,113}},
["seagreen"]={["RGB"]="2E8B57", ["DEC"]={46,139,87}},
["forestgreen"]={["RGB"]="228B22", ["DEC"]={34,139,34}},
["green"]={["RGB"]="008000", ["DEC"]={0,128,0}},
["darkgreen"]={["RGB"]="006400", ["DEC"]={0,100,0}},
["aqua"]={["RGB"]="00FFFF", ["DEC"]={0,255,255}},
["cyan"]={["RGB"]="00FFFF", ["DEC"]={0,255,255}},
["lightcyan"]={["RGB"]="E0FFFF", ["DEC"]={224,255,255}},
["paleturquoise"]={["RGB"]="AFEEEE", ["DEC"]={175,238,238}},
["aquamarine"]={["RGB"]="7FFFD4", ["DEC"]={127,255,212}},
["turquoise"]={["RGB"]="40E0D0", ["DEC"]={64,224,208}},
["mediumturquoise"]={["RGB"]="48D1CC", ["DEC"]={72,209,204}},
["darkturquoise"]={["RGB"]="00CED1", ["DEC"]={0,206,209}},
["lightseagreen"]={["RGB"]="20B2AA", ["DEC"]={32,178,170}},
["cadetblue"]={["RGB"]="5F9EA0", ["DEC"]={95,158,160}},
["darkcyan"]={["RGB"]="008B8B", ["DEC"]={0,139,139}},
["teal"]={["RGB"]="008080", ["DEC"]={0,128,128}},
["lightsteelblue"]={["RGB"]="B0C4DE", ["DEC"]={176,196,222}},
["powderblue"]={["RGB"]="B0E0E6", ["DEC"]={176,224,230}},
["lightblue"]={["RGB"]="ADD8E6", ["DEC"]={173,216,230}},
["skyblue"]={["RGB"]="87CEEB", ["DEC"]={135,206,235}},
["lightskyblue"]={["RGB"]="87CEFA", ["DEC"]={135,206,250}},
["deepskyblue"]={["RGB"]="00BFFF", ["DEC"]={0,191,255}},
["dodgerblue"]={["RGB"]="1E90FF", ["DEC"]={30,144,255}},
["cornflowerblue"]={["RGB"]="6495ED", ["DEC"]={100,149,237}},
["steelblue"]={["RGB"]="4682B4", ["DEC"]={70,130,180}},
["royalblue"]={["RGB"]="041690", ["DEC"]={65,105,225}},
["blue"]={["RGB"]="0000FF", ["DEC"]={0,0,255}},
["mediumblue"]={["RGB"]="0000CD", ["DEC"]={0,0,205}},
["darkblue"]={["RGB"]="00008B", ["DEC"]={0,0,139}},
["navy"]={["RGB"]="000080", ["DEC"]={0,0,128}},
["midnightblue"]={["RGB"]="191970", ["DEC"]={25,25,112}},
["lavender"]={["RGB"]="E6E6FA", ["DEC"]={230,230,250}},
["thistle"]={["RGB"]="D8BFD8", ["DEC"]={216,191,216}},
["plum"]={["RGB"]="DDA0DD", ["DEC"]={221,160,221}},
["violet"]={["RGB"]="EE82EE", ["DEC"]={238,130,238}},
["orchid"]={["RGB"]="DA70D6", ["DEC"]={218,112,214}},
["fuchsia"]={["RGB"]="FF00FF", ["DEC"]={255,0,255}},
["magenta"]={["RGB"]="FF00FF", ["DEC"]={255,0,255}},
["mediumorchid"]={["RGB"]="BA55D3", ["DEC"]={186,85,211}},
["mediumpurple"]={["RGB"]="9370DB", ["DEC"]={147,112,219}},
["blueviolet"]={["RGB"]="8A2BE2", ["DEC"]={138,43,226}},
["darkviolet"]={["RGB"]="9400D3", ["DEC"]={148,0,211}},
["darkorchid"]={["RGB"]="9932CC", ["DEC"]={153,50,204}},
["darkmagenta"]={["RGB"]="8B008B", ["DEC"]={139,0,139}},
["purple"]={["RGB"]="800080", ["DEC"]={128,0,128}},
["indigo"]={["RGB"]="4B0082", ["DEC"]={75,0,130}},
["darkslateblue"]={["RGB"]="483D8B", ["DEC"]={72,61,139}},
["slateblue"]={["RGB"]="6A5ACD", ["DEC"]={106,90,205}},
["mediumslateblue"]={["RGB"]="7B68EE", ["DEC"]={123,104,238}},
["white"]={["RGB"]="FFFFFF", ["DEC"]={255,255,255}},
["snow"]={["RGB"]="FFFAFA", ["DEC"]={255,250,250}},
["honeydew"]={["RGB"]="F0FFF0", ["DEC"]={240,255,240}},
["mintcream"]={["RGB"]="F5FFFA", ["DEC"]={245,255,250}},
["azure"]={["RGB"]="F0FFFF", ["DEC"]={240,255,255}},
["aliceblue"]={["RGB"]="F0F8FF", ["DEC"]={240,248,255}},
["ghostwhite"]={["RGB"]="F8F8FF", ["DEC"]={248,248,255}},
["whitesmoke"]={["RGB"]="F5F5F5", ["DEC"]={245,245,245}},
["seashell"]={["RGB"]="FFF5EE", ["DEC"]={255,245,238}},
["beige"]={["RGB"]="F5F5DC", ["DEC"]={245,245,220}},
["oldlace"]={["RGB"]="FDF5E6", ["DEC"]={253,245,230}},
["floralwhite"]={["RGB"]="FFFAF0", ["DEC"]={255,250,240}},
["ivory"]={["RGB"]="FFFFF0", ["DEC"]={255,255,240}},
["antiquewhite"]={["RGB"]="FAEBD7", ["DEC"]={250,235,215}},
["linen"]={["RGB"]="FAF0E6", ["DEC"]={250,240,230}},
["lavenderblush"]={["RGB"]="FFF0F5", ["DEC"]={255,240,245}},
["mistyrose"]={["RGB"]="FFE4E1", ["DEC"]={255,228,225}},
["gainsboro"]={["RGB"]="DCDCDC", ["DEC"]={220,220,220}},
["lightgrey"]={["RGB"]="D3D3D3", ["DEC"]={211,211,211}},
["silver"]={["RGB"]="C0C0C0", ["DEC"]={192,192,192}},
["darkgray"]={["RGB"]="A9A9A9", ["DEC"]={169,169,169}},
["gray"]={["RGB"]="808080", ["DEC"]={128,128,128}},
["dimgray"]={["RGB"]="696969", ["DEC"]={105,105,105}},
["lightslategray"]={["RGB"]="778899", ["DEC"]={119,136,153}},
["slategray"]={["RGB"]="708090", ["DEC"]={112,128,144}},
["darkslategray"]={["RGB"]="2F4F4F", ["DEC"]={47,79,79}},
["black"]={["RGB"]="000000", ["DEC"]={0,0,0}}
}
local materialNames = {
"Plastic",
"Wood",
"Slate",
"Concrete",
"CorrodedMetal",
"DiamondPlate",
"Foil",
"Grass",
"Ice",
"Marble",
"Granite",
"Brick",
"Pebble",
"Sand",
"Fabric",
"SmoothPlastic",
"Metal",
"WoodPlanks",
"Cobblestone",
"Air",
"Water",
"Rock",
"Glacier",
"Snow",
"Sandstone",
"Mud",
"Basalt",
"Ground",
"CrackedLava",
"Neon",
"Glass",
"Asphalt",
"LeafyGrass",
"Salt",
"Limestone",
"Pavement",
"ForceField"
}
--This function returns a string value
function shapes.helloWorld()
return "Hello World"
end
--[[
CUBE ------------------------------------------------------------------
This function creates a cube
A variable number of arguments (from none to 6) can be provided:
size
x, y, z
x, y, z, size
x, y, z, size, color
x, y, z, size, color, material
The non-numeric arguments will be of specific types: string, Color3, Enum.Material. Because these arguments have specific types,
the function will examine the arguments, determine their type, and then use them as specific parameters for the function based on the argument type.
The non-numeric arguments can be placed in any order in any position of the arguments list
For examples:
color, material, size
size, color, material
color, x, y, z
x, y, z, color
The numeric arguments will always be interpreted as size if only 1 argument and x, y, z if 3 or more arguments.
]]
function shapes.cube(...)
local arguments = table.pack(...)
local size = 10 -- Default size if none specified
local x, y, z = 0, 0, -15
local material = Enum.Material.Plastic
local mainPart = Instance.new("Part")
mainPart.Anchored = true
mainPart.Shape = Enum.PartType.Block
mainPart.TopSurface = Enum.SurfaceType.Smooth
mainPart.BottomSurface = Enum.SurfaceType.Smooth
mainPart.Transparency = 0
mainPart.Reflectance = 0.6
mainPart.Parent = workspace
mainPart.Color = defaultColor
local numNumericArguments = 0
for i = 1, #arguments do
if typeof(arguments[i]) == "number" then numNumericArguments += 1 end
end
local workingNumber = 0
for i = 1, #arguments do
if typeof(arguments[i]) == "Color3" then
mainPart.Color = arguments[i]
end
if typeof(arguments[i]) == "string" then
local color = string.lower(arguments[i])
local red = colorName[color]["DEC"][1]/255 --rescale from 0-255 to 0-1
local green = colorName[color]["DEC"][2]/255 --rescale from 0-255 to 0-1
local blue = colorName[color]["DEC"][3]/255 --rescale from 0-255 to 0-1
mainPart.Color = Color3.new(red, green, blue)
end
if typeof(arguments[i]) == "EnumItem" then
mainPart.Material = arguments[i]
end
if typeof(arguments[i]) == "number" then
if numNumericArguments == 1 then
size = arguments[i]
y = size/2
else
workingNumber += 1
if workingNumber == 1 then x = arguments[i] end
if workingNumber == 2 then y = arguments[i] end
if workingNumber == 3 then z = arguments[i] end
if workingNumber == 4 then size = arguments[i] end
end
end
end
if numNumericArguments == 0 then
y = size/2
end
mainPart.Size = Vector3.new(size,size,size)
mainPart.Position = Vector3.new(x,y,z)
return mainPart
end
--[[
PANEL ------------------------------------------------------------------
This function creates a panel
A variable number of arguments (from none to 6) can be provided:
size
width, height
width, height, thickness
x, y, z
x, y, z, size
x, y, z, width, height
x, y, z, width, height, thickness
x, y, z, width, height, size, thickness, color
x, y, z, width, height, size, thickness, color, material
The non-numeric arguments will be of specific types: string, Color3, Enum.Material. Because these arguments have specific types,
the function will examine the arguments, determine their type, and then use them as specific parameters for the function based on the argument type.
The non-numeric arguments can be placed in any order in any position of the arguments list
For examples:
color, material, width, height
size, color, material
color, x, y, z
x, y, z, material, color
The numeric arguments will always be interpreted as size if only 1 argument and x, y, z if 3 or more arguments.
]]
function shapes.panel(...)
local arguments = table.pack(...)
local width = 10 -- Default size if none specified
local height = 10 -- Default size if none specified
local thickness = 0.1
local x, y, z = 0, 0, -15
local color = defaultColor
local material = Enum.Material.Plastic
if thickness < 0.1 then thickness = 0.1 end
local mainPart = Instance.new("Part")
mainPart.Anchored = true
mainPart.Shape = Enum.PartType.Block
mainPart.TopSurface = Enum.SurfaceType.Smooth
mainPart.BottomSurface = Enum.SurfaceType.Smooth
mainPart.FrontSurface = Enum.SurfaceType.Smooth
mainPart.BackSurface = Enum.SurfaceType.Smooth
mainPart.LeftSurface = Enum.SurfaceType.Smooth
mainPart.RightSurface = Enum.SurfaceType.Smooth
mainPart.Transparency = 0
mainPart.Reflectance = 0
mainPart.Parent = workspace
mainPart.Color = defaultColor
local numNumericArguments = 0
for i = 1, #arguments do
if typeof(arguments[i]) == "number" then numNumericArguments += 1 end
end
local workingNumber = 0
for i = 1, #arguments do
if typeof(arguments[i]) == "Color3" then
mainPart.Color = arguments[i]
end
if typeof(arguments[i]) == "string" then
local color = string.lower(arguments[i])
local red = colorName[color]["DEC"][1]/255 --rescale from 0-255 to 0-1
local green = colorName[color]["DEC"][2]/255 --rescale from 0-255 to 0-1
local blue = colorName[color]["DEC"][3]/255 --rescale from 0-255 to 0-1
mainPart.Color = Color3.new(red, green, blue)
end
if typeof(arguments[i]) == "EnumItem" then
mainPart.Material = arguments[i]
end
if typeof(arguments[i]) == "number" then
if numNumericArguments == 1 then
width = arguments[i]
height = arguments[i]
y = height/2
elseif numNumericArguments == 3 then
workingNumber += 1
if workingNumber == 1 then width = arguments[i] end
if workingNumber == 2 then height = arguments[i] end
if workingNumber == 3 then thickness = arguments[i] end
y = height/2
elseif numNumericArguments == 4 then
workingNumber += 1
if workingNumber == 1 then x = arguments[i] end
if workingNumber == 2 then y = arguments[i] end
if workingNumber == 3 then z = arguments[i] end
if workingNumber == 4 then
width = arguments[i]
height = arguments[i]
end
elseif numNumericArguments == 5 then
workingNumber += 1
if workingNumber == 1 then x = arguments[i] end
if workingNumber == 2 then y = arguments[i] end
if workingNumber == 3 then z = arguments[i] end
if workingNumber == 4 then width = arguments[i] end
if workingNumber == 5 then height = arguments[i] end
elseif numNumericArguments == 6 then
workingNumber += 1
if workingNumber == 1 then x = arguments[i] end
if workingNumber == 2 then y = arguments[i] end
if workingNumber == 3 then z = arguments[i] end
if workingNumber == 4 then width = arguments[i] end
if workingNumber == 5 then height = arguments[i] end
if workingNumber == 6 then thickness = arguments[i] end
else
workingNumber += 1
if workingNumber == 1 then x = arguments[i] end
if workingNumber == 2 then y = arguments[i] end
if workingNumber == 3 then z = arguments[i] end
if workingNumber == 4 then
width = arguments[i]
height = arguments[i]
end
end
end
end
if numNumericArguments == 0 then y = width/2 end
mainPart.Size = Vector3.new(width,thickness,height)
mainPart.Orientation = Vector3.new(90, 0, 0)
mainPart.Position = Vector3.new(x,y,z)
return mainPart
end
--[[
-- SQUARE ------------------------------------------------------------------
-- This function creates a square
-- A variable number of arguments (from none to 6) can be provided:
-- size
-- size, thickness
-- x, y, z
-- x, y, z, size
-- x, y, z, size, thickness
-- x, y, z, size, thickness, color
-- x, y, z, size, thickness, color, material
The non-numeric arguments will be of specific types: string, Color3, Enum.Material. Because these arguments have specific types,
the function will examine the arguments, determine their type, and then use them as specific parameters for the function based on the argument type.
The non-numeric arguments can be placed in any order in any position of the arguments list
For examples:
color, material, size, thickness
size, color, material
color, x, y, z
x, y, z, material, color
The numeric arguments will always be interpreted as size if only 1 argument and x, y, z if 3 or more arguments.
]]
function shapes.square(...)
local arguments = table.pack(...)
local numNumericArguments = 0
for i = 1, #arguments do
if typeof(arguments[i]) == "number" then numNumericArguments += 1 end
end
local size = 10 -- Default size if none specified
local thickness = defaultBorderThickness
local x, y, z = 0, 0, -15
local color = defaultColor
local material = Enum.Material.Plastic
local workingNumber = 0
for i = 1, #arguments do
if typeof(arguments[i]) == "Color3" then
color = arguments[i]
end
if typeof(arguments[i]) == "string" then
color = string.lower(arguments[i])
local red = colorName[color]["DEC"][1]/255 --rescale from 0-255 to 0-1
local green = colorName[color]["DEC"][2]/255 --rescale from 0-255 to 0-1
local blue = colorName[color]["DEC"][3]/255 --rescale from 0-255 to 0-1
color = Color3.new(red, green, blue)
end
if typeof(arguments[i]) == "EnumItem" then
material = arguments[i]
end
if typeof(arguments[i]) == "number" then
if numNumericArguments == 1 then
size = arguments[i]
elseif numNumericArguments == 2 then
workingNumber += 1
if workingNumber == 1 then size = arguments[i] end
if workingNumber == 2 then thickness = arguments[i] end
elseif numNumericArguments == 4 then
workingNumber += 1
if workingNumber == 1 then x = arguments[i] end
if workingNumber == 2 then y = arguments[i] end
if workingNumber == 3 then z = arguments[i] end
if workingNumber == 4 then size = arguments[i] end
else
workingNumber += 1
if workingNumber == 1 then x = arguments[i] end
if workingNumber == 2 then y = arguments[i] end
if workingNumber == 3 then z = arguments[i] end
if workingNumber == 4 then size = arguments[i] end
if workingNumber == 5 then thickness = arguments[i] end
end
end
end
if thickness < 0.1 then thickness = 0.1 end
local panel = Instance.new("Part")
panel.Anchored = true
panel.Shape = Enum.PartType.Block
panel.TopSurface = Enum.SurfaceType.Smooth
panel.BottomSurface = Enum.SurfaceType.Smooth
panel.Transparency = 0
panel.Reflectance = 0
panel.Parent = workspace
panel.Size = Vector3.new(size,thickness,size)
panel.Position = panel.Position + Vector3.new(x,y,z)
panel.Color = color
local panelN = Instance.new("Part")
panelN.Anchored = true
panelN.Shape = Enum.PartType.Block
panelN.TopSurface = Enum.SurfaceType.Smooth
panelN.BottomSurface = Enum.SurfaceType.Smooth
panelN.Transparency = 0
panelN.Reflectance = 0
panelN.Parent = workspace
panelN.Size = Vector3.new(size-thickness,1,size-thickness)
panelN.Position += Vector3.new(x,y,z)
panelN.Color = color
local otherParts = {panelN}
-- Perform subtract operation
local success, newSquare = pcall(function()
return panel:SubtractAsync(otherParts)
end)
-- If operation succeeds, position it at the same location and parent it to the workspace
if success and newSquare then
newSquare.Position = panel.Position
newSquare.Parent = workspace
end
-- Destroy original parts which remain intact after operation
panel:Destroy()
for i = 1, #otherParts do
otherParts[i]:Destroy()
end
if numNumericArguments <= 2 then y = size/2 end
newSquare.Material = material
newSquare.Color = color
newSquare.Size = Vector3.new(size,thickness,size)
newSquare.Orientation = Vector3.new(90, 0, 0)
newSquare.Position = Vector3.new(x,y,z)
return newSquare
end
--[[
RECTANGLE ------------------------------------------------------------------
This function creates a rectangle
A variable number of arguments (from none to 6) can be provided:
size
width, height
width, height, thickness
x, y, z
x, y, z, size
x, y, z, width, height
x, y, z, width, height, thickness
x, y, z, width, height, thickness, color
x, y, z, width, height, thickness, color, material
The non-numeric arguments will be of specific types: string, Color3, Enum.Material. Because these arguments have specific types,
the function will examine the arguments, determine their type, and then use them as specific parameters for the function based on the argument type.
The non-numeric arguments can be placed in any order in any position of the arguments list
For examples:
color, material, size, thickness
size, color, material
color, x, y, z
x, y, z, material, color
The numeric arguments will always be interpreted as size if only 1 argument and x, y, z if 3 or more arguments.
]]
function shapes.rectangle(...)
local arguments = table.pack(...)
local numNumericArguments = 0
for i = 1, #arguments do
if typeof(arguments[i]) == "number" then numNumericArguments += 1 end
end
local width = 10 -- Default size if none specified
local height = 10 -- Default size if none specified
local thickness = defaultBorderThickness
local x, y, z = 0, 0, -15
local color = defaultColor
local material = Enum.Material.Plastic
local workingNumber = 0
for i = 1, #arguments do
if typeof(arguments[i]) == "Color3" then
color = arguments[i]
end
if typeof(arguments[i]) == "string" then
color = string.lower(arguments[i])
local red = colorName[color]["DEC"][1]/255 --rescale from 0-255 to 0-1
local green = colorName[color]["DEC"][2]/255 --rescale from 0-255 to 0-1
local blue = colorName[color]["DEC"][3]/255 --rescale from 0-255 to 0-1
color = Color3.new(red, green, blue)
--print(tostring(red) .. " " .. tostring(green) .. " " .. tostring(blue))
--print(tostring(newSquare.Color))
end
if typeof(arguments[i]) == "EnumItem" then
material = arguments[i]
end
if typeof(arguments[i]) == "number" then
if numNumericArguments == 1 then
width = arguments[i]
height = arguments[i]
elseif numNumericArguments == 2 then
workingNumber += 1
if workingNumber == 1 then width = arguments[i] end
if workingNumber == 2 then height = arguments[i] end
elseif numNumericArguments == 3 then
workingNumber += 1
if workingNumber == 1 then width = arguments[i] end
if workingNumber == 2 then height = arguments[i] end
if workingNumber == 3 then thickness = arguments[i] end
elseif numNumericArguments == 4 then
workingNumber += 1
if workingNumber == 1 then x = arguments[i] end
if workingNumber == 2 then y = arguments[i] end
if workingNumber == 3 then z = arguments[i] end
if workingNumber == 4 then
width = arguments[i]
height = arguments[i]
end
elseif numNumericArguments == 5 then
workingNumber += 1
if workingNumber == 1 then x = arguments[i] end
if workingNumber == 2 then y = arguments[i] end
if workingNumber == 3 then z = arguments[i] end
if workingNumber == 4 then width = arguments[i] end
if workingNumber == 5 then height = arguments[i] end
else
workingNumber += 1
if workingNumber == 1 then x = arguments[i] end
if workingNumber == 2 then y = arguments[i] end
if workingNumber == 3 then z = arguments[i] end
if workingNumber == 4 then width = arguments[i] end
if workingNumber == 5 then height = arguments[i] end
if workingNumber == 6 then thickness = arguments[i] end
end
end
end
if thickness < 0.1 then thickness = 0.1 end
local panel = Instance.new("Part")
panel.Anchored = true
panel.Shape = Enum.PartType.Block
panel.TopSurface = Enum.SurfaceType.Smooth
panel.BottomSurface = Enum.SurfaceType.Smooth
panel.Transparency = 0
panel.Reflectance = 0
panel.Parent = workspace
panel.Size = Vector3.new(width,thickness,height)
panel.Position = panel.Position + Vector3.new(x,y,z)
panel.Color = color
local panelN = Instance.new("Part")
panelN.Anchored = true
panelN.Shape = Enum.PartType.Block
panelN.TopSurface = Enum.SurfaceType.Smooth
panelN.BottomSurface = Enum.SurfaceType.Smooth
panelN.Transparency = 0
panelN.Reflectance = 0
panelN.Parent = workspace
panelN.Size = Vector3.new(width-thickness,1,height-thickness)
panelN.Position += Vector3.new(x,y,z)
panelN.Color = color
local otherParts = {panelN}
-- Perform subtract operation
local success, newSquare = pcall(function()
return panel:SubtractAsync(otherParts)
end)
-- If operation succeeds, position it at the same location and parent it to the workspace
if success and newSquare then
newSquare.Position = panel.Position
newSquare.Parent = workspace
end
-- Destroy original parts which remain intact after operation
panel:Destroy()
for i = 1, #otherParts do
otherParts[i]:Destroy()
end
newSquare.Color = color
newSquare.Orientation = Vector3.new(90, 0, 0)
newSquare.Position = Vector3.new(x,y,z)
newSquare.Material = material
return newSquare
end
-- DISC ------------------------------------------------------------------
-- This function creates a disc
-- A variable number of arguments (from none to 6) can be provided:
-- size
-- size, thickness
-- x, y, z
-- x, y, z, size
-- x, y, z, size, thickness
-- x, y, z, size, thickness, color
-- x, y, z, size, thickness, color, material
function shapes.disc(...)
local arguments = table.pack(...)
local numNumericArguments = 0
for i = 1, #arguments do
if typeof(arguments[i]) == "number" then numNumericArguments += 1 end
end
local size = 10 -- Default size if none specified
local thickness = 0.1
local x, y, z = 0, 0, -15
local color = defaultColor
local material = Enum.Material.Plastic
if #arguments < 3 then
size = arguments[1]
y = size/2
elseif #arguments == 3 then x,y,z = arguments[1],arguments[2],arguments[3]
elseif #arguments == 4 then x,y,z, size = arguments[1],arguments[2],arguments[3],arguments[4]
elseif #arguments == 5 then x,y,z, size, thickness = arguments[1],arguments[2],arguments[3],arguments[4],arguments[5]
elseif #arguments == 6 then x,y,z, size, thickness, color = arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6]
elseif #arguments == 7 then x,y,z, size, thickness, color, material = arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6],arguments[7]
elseif #arguments > 8 then print("Too many arguments")
else
end
if thickness < 0.1 then thickness = 0.1 end
local mainPart = Instance.new("Part")
mainPart.Anchored = true
mainPart.Shape = Enum.PartType.Cylinder
mainPart.TopSurface = Enum.SurfaceType.Smooth
mainPart.BottomSurface = Enum.SurfaceType.Smooth
mainPart.Transparency = 0
mainPart.Reflectance = 0.6
mainPart.Parent = workspace
mainPart.Orientation = Vector3.new(90,0,90) -- must stay 90, 0, 90
mainPart.Size = Vector3.new(thickness,size,size) -- must stay thickness, size, size
mainPart.Position = Vector3.new(x,y,z)
if typeof(color) == "Color3" then
mainPart.Color = color
else
if typeof(color) == "string" then
color = string.lower(color)
local red = colorName[color]["DEC"][1]/255 --rescale from 0-255 to 0-1
local green = colorName[color]["DEC"][2]/255 --rescale from 0-255 to 0-1
local blue = colorName[color]["DEC"][3]/255 --rescale from 0-255 to 0-1
mainPart.Color = Color3.new(red, green, blue)
end
end
mainPart.Material = material
return mainPart
end
-- CIRCLE ------------------------------------------------------------------
-- This function creates a circle
-- A variable number of arguments (from none to 6) can be provided:
-- size
-- size, thickness
-- x, y, z
-- x, y, z, size
-- x, y, z, size, thickness
-- x, y, z, size, thickness, color
-- x, y, z, size, thickness, color, material
function shapes.circle(...)
local arguments = table.pack(...)
local numNumericArguments = 0
for i = 1, #arguments do
if typeof(arguments[i]) == "number" then numNumericArguments += 1 end
end
local size = 10 -- Default size if none specified
local thickness = defaultBorderThickness
local x, y, z = 0, 0, -15
local color = defaultColor
local material = Enum.Material.Plastic
if #arguments < 3 then
size = arguments[1]
y = size/2
elseif #arguments == 3 then x,y,z = arguments[1],arguments[2],arguments[3]
elseif #arguments == 4 then x,y,z, size = arguments[1],arguments[2],arguments[3],arguments[4]
elseif #arguments == 5 then x,y,z, size, thickness = arguments[1],arguments[2],arguments[3],arguments[4],arguments[5]
elseif #arguments == 6 then x,y,z, size, thickness, color = arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6]
elseif #arguments == 7 then x,y,z, size, thickness, color, material = arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6],arguments[7]
elseif #arguments > 8 then print("Too many arguments")
else
end
if thickness < 0.1 then thickness = 0.1 end
local disc = Instance.new("Part")
disc.Anchored = true
disc.Shape = Enum.PartType.Cylinder
disc.TopSurface = Enum.SurfaceType.Smooth
disc.BottomSurface = Enum.SurfaceType.Smooth
disc.Transparency = 0
disc.Reflectance = 0.6
disc.Parent = workspace
disc.Size = Vector3.new(thickness,size,size)
disc.Orientation = Vector3.new(0, 90, 0)
local zCoord = -15
local xCoord = 0
disc.Position = disc.Position + Vector3.new(xCoord,size/2,zCoord)
local discN = Instance.new("Part")
discN.Anchored = true
discN.Shape = Enum.PartType.Cylinder
discN.TopSurface = Enum.SurfaceType.Smooth
discN.BottomSurface = Enum.SurfaceType.Smooth
discN.Transparency = 0
discN.Reflectance = 0.6
discN.Parent = workspace
discN.Size = Vector3.new(thickness+2,size-thickness,size-thickness)
discN.Orientation = Vector3.new(0, 90, 0)
local zCoord = -15
local xCoord = 0
discN.Position = discN.Position + Vector3.new(xCoord,size/2,zCoord)
--print(typeof(discN.Position))
local otherParts = {discN}
-- Perform subtract operation
local success, newCircle = pcall(function()
return disc:SubtractAsync(otherParts)
end)
-- If operation succeeds, position it at the same location and parent it to the workspace
if success and newCircle then
newCircle.Position = disc.Position
newCircle.Parent = workspace
end
-- Destroy original parts which remain intact after operation
disc:Destroy()
for i = 1, #otherParts do
otherParts[i]:Destroy()
end
newCircle.Archivable=true
newCircle.Position = Vector3.new(x, y, z)
if typeof(color) == "Color3" then
newCircle.Color = color
else
if typeof(color) == "string" then
color = string.lower(color)
local red = colorName[color]["DEC"][1]/255 --rescale from 0-255 to 0-1
local green = colorName[color]["DEC"][2]/255 --rescale from 0-255 to 0-1
local blue = colorName[color]["DEC"][3]/255 --rescale from 0-255 to 0-1
newCircle.Color = Color3.new(red, green, blue)
end
end
--newCircle:SetAttribute("A", 4)
--print(typeof(newCircle.Position))
return newCircle
end
-- SPHERE ------------------------------------------------------------------
-- This function creates a sphere
-- A variable number of arguments (from none to 6) can be provided:
-- size
-- x, y, z
-- x, y, z, size
-- x, y, z, size, color
-- x, y, z, size, color, material
function shapes.sphere(...)
local arguments = table.pack(...)
local numNumericArguments = 0
for i = 1, #arguments do
if typeof(arguments[i]) == "number" then numNumericArguments += 1 end
end
local size = 10 -- Default size if none specified
local x, y, z = 0, 0, -15
local color = defaultColor
local material = Enum.Material.Plastic
if #arguments == 1 then
size = arguments[1]
y = size/2
elseif #arguments == 3 then x,y,z = arguments[1],arguments[2],arguments[3]
elseif #arguments == 4 then x,y,z, size = arguments[1],arguments[2],arguments[3],arguments[4]
elseif #arguments == 5 then x,y,z, size, color = arguments[1],arguments[2],arguments[3],arguments[4],arguments[5]
elseif #arguments == 6 then x,y,z, size, color, material = arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6]
elseif #arguments > 6 then print("Too many arguments")
else
end
local mainPart = Instance.new("Part")
mainPart.Anchored = true
mainPart.Shape = Enum.PartType.Ball
mainPart.TopSurface = Enum.SurfaceType.Smooth
mainPart.BottomSurface = Enum.SurfaceType.Smooth
mainPart.Transparency = 0
mainPart.Reflectance = 0.6
mainPart.Parent = workspace
mainPart.Size = Vector3.new(size,size,size)
if typeof(color) == "Color3" then
mainPart.Color = color
else
if typeof(color) == "string" then
color = string.lower(color)
local red = colorName[color]["DEC"][1]/255 --rescale from 0-255 to 0-1
local green = colorName[color]["DEC"][2]/255 --rescale from 0-255 to 0-1
local blue = colorName[color]["DEC"][3]/255 --rescale from 0-255 to 0-1
mainPart.Color = Color3.new(red, green, blue)
end
end
mainPart.Position = Vector3.new(x,y,z)
mainPart.Material = material
return mainPart
end
-- LIGHTSOURCE ------------------------------------------------------------------
-- This function creates a lightSource
-- A variable number of arguments (from none to 6) can be provided:
-- size
-- width, height
-- width, height, thickness
-- x, y, z
-- x, y, z, size
-- x, y, z, width, height
-- x, y, z, width, height, thickness
-- x, y, z, width, height, size, thickness, color
-- x, y, z, width, height, size, thickness, color, material
function shapes.lightSource(...)
local arguments = table.pack(...)
local width = 10 -- Default size if none specified
local height = 10 -- Default size if none specified
local thickness = 0.1
local x, y, z = 0, 0, -15
local color = defaultColor
local material = Enum.Material.Plastic
if #arguments == 1 then
width = arguments[1]
height = arguments[1]
y = height/2
elseif #arguments == 2 then
width,height = arguments[1],arguments[2]
y = height/2
elseif #arguments == 3 then
width,height,thickness = arguments[1],arguments[2],arguments[3]
y = height/2
elseif #arguments == 4 then x,y,z, width, height = arguments[1],arguments[2],arguments[3],arguments[4],arguments[4]
elseif #arguments == 5 then x,y,z, width, height = arguments[1],arguments[2],arguments[3],arguments[4],arguments[5]
elseif #arguments == 6 then x,y,z, width, height, thickness = arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6]
elseif #arguments == 7 then x,y,z, width, height, thickness, color = arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6],arguments[7]
elseif #arguments == 8 then x,y,z, width, height, thickness, color, material = arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6],arguments[7],arguments[8]
elseif #arguments > 9 then print("Too many arguments")
else
end
if thickness < 0.1 then thickness = 0.1 end
local mainPart = Instance.new("Part")
mainPart.Anchored = true
mainPart.Shape = Enum.PartType.Block
mainPart.TopSurface = Enum.SurfaceType.Smooth
mainPart.BottomSurface = Enum.SurfaceType.Smooth
mainPart.FrontSurface = Enum.SurfaceType.Smooth
mainPart.BackSurface = Enum.SurfaceType.Smooth
mainPart.LeftSurface = Enum.SurfaceType.Smooth
mainPart.RightSurface = Enum.SurfaceType.Smooth
mainPart.Transparency = 0
mainPart.Reflectance = 0
mainPart.Parent = workspace
mainPart.Size = Vector3.new(width,thickness,height)
mainPart.Orientation = Vector3.new(90, 0, 0)
if typeof(color) == "Color3" then
mainPart.Color = color
else
if typeof(color) == "string" then
color = string.lower(color)
local red = colorName[color]["DEC"][1]/255 --rescale from 0-255 to 0-1
local green = colorName[color]["DEC"][2]/255 --rescale from 0-255 to 0-1
local blue = colorName[color]["DEC"][3]/255 --rescale from 0-255 to 0-1
mainPart.Color = Color3.new(red, green, blue)
end
end
mainPart.Color = color
mainPart.Position = Vector3.new(x,y,z)
mainPart.Material = material
local lightOfPart = Instance.new("SurfaceLight")
lightOfPart.Color = Color3.fromRGB(255, 255, 255)
lightOfPart.Brightness = 600
lightOfPart.Range = 30
lightOfPart.Parent = mainPart
return mainPart
end
--This will subtract part B from part A
function shapes.subtract(mainPart, subPart)
local success, newMainPart = pcall(function()
return mainPart:SubtractAsync({subPart})
end)
-- If operation succeeds, position it at the same location and parent it to the workspace
if success and newMainPart then
newMainPart.Position = mainPart.Position
newMainPart.Parent = workspace
end
-- Destroy original parts which remain intact after operation
mainPart:Destroy()
subPart:Destroy()
return newMainPart
end
--This will Union part B to part A
function shapes.union(mainPart, subPartList)
local success, newMainPart = pcall(function()
return mainPart:UnionAsync(subPartList)
end)
-- If operation succeeds, position it at the same location and parent it to the workspace
if success and newMainPart then
newMainPart.Position = mainPart.Position
newMainPart.Parent = workspace
end
-- Destroy original parts which remain intact after operation
mainPart:Destroy()
for i = 1, #subPartList do
subPartList[i]:Destroy()
end
return newMainPart
end
--This function changes the color of the object
function shapes.fill(mainPart, colorValue)
if typeof(colorValue) == "Color3" then
mainPart.Color = colorValue
else
if typeof(colorValue) == "string" then
colorValue = string.lower(colorValue)
local red = colorName[colorValue]["DEC"][1]/255 --rescale from 0-255 to 0-1
local green = colorName[colorValue]["DEC"][2]/255 --rescale from 0-255 to 0-1
local blue = colorName[colorValue]["DEC"][3]/255 --rescale from 0-255 to 0-1
mainPart.Color = Color3.new(red, green, blue)
else
print("Error in the Fill method. You need to pass a Color3 vector or a string")
end
end
return mainPart
end
--This function changes the location of the object
function shapes.moveBy(...)
local arguments = table.pack(...)
local x, y, z = 0, 0, 0
local moveValue = 0
local mainPart = arguments[1]
if #arguments == 2 then
mainPart = arguments[1]
moveValue = arguments[2]
elseif #arguments == 4 then moveValue = Vector3.new(arguments[2],arguments[3],arguments[4])
else
end
if typeof(moveValue) == "Vector3" then
mainPart.Position += moveValue
else
print("Error in the moveBy method. You need to pass a Vector3. You passed a: "..typeof(moveValue))
end
return mainPart
end
--This function changes the location of the object
function shapes.moveTo(...)
local arguments = table.pack(...)
local x, y, z = 0, 0, 0
local locationValue = 0
local mainPart = arguments[1]
if #arguments == 2 then
mainPart = arguments[1]
locationValue = arguments[2]
elseif #arguments == 4 then locationValue = Vector3.new(arguments[2],arguments[3],arguments[4])
else
end
if typeof(locationValue) == "Vector3" then
mainPart.Position = locationValue
else
print("Error in the moveTo method. You need to pass a Vector3. You passed a: "..typeof(locationValue))
end
return mainPart
end
--This function changes the size of the object
function shapes.size(mainPart, sizeValue)
if typeof(sizeValue) == "Vector3" then
mainPart.Size = sizeValue
else
print("Error in the Size method. You need to pass a Vector3. You passed a: "..typeof(sizeValue))
end
return mainPart
end
--This function changes the size of the object
function shapes.resizeBy(mainPart, sizeValue)
if typeof(sizeValue) == "Vector3" then
mainPart.Size += sizeValue
else
print("Error in the Size method. You need to pass a Vector3. You passed a: "..typeof(sizeValue))
end
return mainPart
end
--This function changes the rotation of the object
function shapes.rotate(...)
local arguments = table.pack(...)
local rotateValue = 0
local mainPart = arguments[1]
if #arguments == 2 then
mainPart = arguments[1]
rotateValue = arguments[2]
elseif #arguments == 4 then rotateValue = Vector3.new(arguments[2],arguments[3],arguments[4])
else
end
if typeof(rotateValue) == "Vector3" then
mainPart.Orientation = rotateValue
else
print("Error in the Rotation method. You need to pass a Vector3. You passed a: "..typeof(rotateValue))
end
return mainPart
end
--This function changes the rotation of the object
function shapes.rotateBy(...)
local arguments = table.pack(...)
local rotateValue = 0
local mainPart = arguments[1]
if #arguments == 2 then
mainPart = arguments[1]
rotateValue = arguments[2]
elseif #arguments == 4 then rotateValue = Vector3.new(arguments[2],arguments[3],arguments[4])
else
end
if typeof(rotateValue) == "Vector3" then
--mainPart.Orientation += rotateValue
--mainPart.CFrame += rotateValue
local pivot = mainPart.Position
local newpivot = CFrame.new(pivot) -- Create decoy pivot that will "rotate"
local offset = newpivot:toObjectSpace(mainPart.CFrame) -- Get the offset from the part to the pivot
newpivot = newpivot * CFrame.Angles(math.rad(rotateValue.X), math.rad(rotateValue.Y), math.rad(rotateValue.Z)) -- Rotate the pivot
mainPart.CFrame = newpivot * offset -- Re-offset the part from the new rotation
else
print("Error in the Rotation method. You need to pass a Vector3. You passed a: "..typeof(rotateValue))
end
return mainPart
end
--This function changes the transparency of the object
function shapes.transparency(mainPart, value)
if typeof(value) == "number" then
mainPart.Transparency = value
else
print("Error in the Transparency method. You need to pass a number. You passed a: "..typeof(value))
end
return mainPart
end
--This function changes the reflectance of the object
function shapes.reflectance(mainPart, value)
if typeof(value) == "number" then
mainPart.Reflectance = value
else
print("Error in the Reflectance method. You need to pass a number. You passed a: "..typeof(value))
end
return mainPart
end
--This function changes the material of the object
function shapes.material(mainPart, value)
--local Materials = Enum.Material:GetEnumItems()
if typeof(value) == "string" or typeof(value) == "EnumItem" then
mainPart.Material = value
else
print("Error in the Material method. You need to pass a string. You passed a: "..typeof(value))
end
return mainPart
end
return shapes
Buildings
Example:
local building = {}
local ServerStorage = game:GetService("ServerStorage")
local s = require(ServerStorage.genericShapes)
function building.room()
local mainPart = s.cube(10, 1)
s.size(mainPart,Vector3.new(26,3,26))
local hollowPart = s.cube(10, 1)
s.size(hollowPart,Vector3.new(23,3,23))
mainPart = s.subtract(mainPart, hollowPart)
s.material(mainPart, "Rock")
mainPart.Position = mainPart.Position + Vector3.new(0, -3, 0)
return mainPart
end
function building.createArchway(xCoord,yCoord,zCoord,xScale,yScale,zScale,xRotate,yRotate,zRotate)
-- Create the block for a doorway
local mainPart = Instance.new("Part")
mainPart.Name = "Doorway"
mainPart.Anchored = true
mainPart.Shape = Enum.PartType.Block
mainPart.CanCollide = true
mainPart.Color = Color3.new(math.random(), math.random(), math.random())
mainPart.TopSurface = Enum.SurfaceType.Smooth
mainPart.BottomSurface = Enum.SurfaceType.Smooth
mainPart.Transparency = 0
mainPart.Reflectance = 0.6
mainPart.Parent = workspace
mainPart.Size = Vector3.new(12,20,2)
local zCoord = -15
local xCoord = 0
mainPart.Position = mainPart.Position + Vector3.new(xCoord,2,zCoord)
-- Create the inner arch
local archPart = Instance.new("Part")
archPart.Name = "Arch"
archPart.Anchored = true
archPart.Shape = Enum.PartType.Cylinder
archPart.CanCollide = false
archPart.Color = Color3.new(math.random(), math.random(), math.random())
archPart.TopSurface = Enum.SurfaceType.Smooth
archPart.BottomSurface = Enum.SurfaceType.Smooth
archPart.Transparency = 0
archPart.Reflectance = 0.6
archPart.Parent = workspace
archPart.Size = Vector3.new(4,60,6)
archPart.Orientation = Vector3.new(0, 90, 0)
local yCoord = 7
local xCoord = 0
archPart.Position = archPart.Position + Vector3.new(xCoord,yCoord,zCoord)
-- Create the bottom through
local walkThruPart = Instance.new("Part")
walkThruPart.Name = "Arch"
walkThruPart.Anchored = true
walkThruPart.Shape = Enum.PartType.Block
walkThruPart.CanCollide = false
walkThruPart.Color = Color3.new(math.random(), math.random(), math.random())
walkThruPart.TopSurface = Enum.SurfaceType.Smooth
walkThruPart.BottomSurface = Enum.SurfaceType.Smooth
walkThruPart.Transparency = 0
walkThruPart.Reflectance = 0.6
walkThruPart.Parent = workspace
walkThruPart.Size = Vector3.new(5.8,8,4)
local yCoord = 4
local xCoord = 0
walkThruPart.Position = walkThruPart.Position + Vector3.new(xCoord,yCoord,zCoord)
local otherParts = {archPart, walkThruPart}
-- Perform subtract operation
local success, newArchway = pcall(function()
return mainPart:SubtractAsync(otherParts)
end)
-- If operation succeeds, position it at the same location and parent it to the workspace
if success and newArchway then
newArchway.Position = mainPart.Position
newArchway.Parent = workspace
end
-- Destroy original parts which remain intact after operation
mainPart:Destroy()
for i = 1, #otherParts do
otherParts[i]:Destroy()
end
-- The resulting Archway is called: newArchway
newArchway.Size= Vector3.new(xScale, yScale, zScale)
newArchway.Position= Vector3.new(xCoord, yCoord, zCoord)
newArchway.Orientation = Vector3.new(xRotate, yRotate, zRotate)
return newArchway
end
return building End of Document