I’m still pretty new to scripting, and this morning I watched some tutorials on functions, parameters, and arguments. For the past hour or so, I’ve been experimenting with the new API I’ve learned, and I wrote the following code, which generates 2 different parts and prints a statement after each:
function generatePart(name, color, transparency, material) local part = Instance.new("Part") part.Name = name part.BrickColor = BrickColor.new(color) part.Anchored = true part.Transparency = transparency part.Material = material part.Parent = workspace end function printText(text) print(text) end generatePart("GrassPart", "Shamrock", 0, Enum.Material.Grass) printText("GrassPart was created.") wait(5) generatePart("GlassPart", "Light blue", 0.2, Enum.Material.Glass) printText("GlassPart was created.")
The code works fine, but I’d like to know if I’m using any practices that aren’t the best, or if there’s a way I can simplify this code or improve it. Thanks!