#how can I improve my grid making script?

1 messages · Page 1 of 1 (latest)

restive glade
#
X,Y = 8,8
ColorChoice = BrickColor.DarkGray()
--Part
local Part = Instance.new("Part")
Part.Size = Vector3.new(4,4,4)
Part.Anchored = true
Part.Material = Enum.Material.SmoothPlastic
--This function changes the color of the grid
function ChangeColor()
    if ColorChoice == BrickColor.Gray() then
        ColorChoice = BrickColor.DarkGray()
    elseif ColorChoice == BrickColor.DarkGray() then
        ColorChoice = BrickColor.Gray()
    end
end

--This Function Makes a Part
function CreateClonedPart(Collum,Row)
    if Row == 1 then
        ChangeColor()
    end
    PartC = Part:Clone()
    ChangeColor()
    PartC.BrickColor = ColorChoice
    PartC.Position = Vector3.new(Collum * Part.Size.X,0,Row * Part.Size.Y)
    PartC.Parent = workspace
end
--[[Grid making Loop]]--
--Clone Part
--Move Part to position offsetted with X
--X will be Collum
--When X is created, also loop through making the y Row
for Collum = 1, X do
    for Row = 1, Y do
        task.wait(.1)
        print(Collum,Row)
        CreateClonedPart(Collum,Row)
    end
end
ornate sentinelBOT
#

studio** You are now Level 13! **studio

wicked dagger
#

here is a beter one

local Start = Vector3.new(0, 8, 0)
local GridX, GridZ = 8, 8

local PartColor = BrickColor.DarkGray()
local PartSize = Vector3.new(4, 4, 4)

function ChangeColor()
    PartColor = (PartColor == BrickColor.Gray()) and BrickColor.DarkGray() or BrickColor.Gray()
end

function CreatePart(X, Z)
    if Z == 1 then ChangeColor() end
    
    ChangeColor()
    
    local Part = Instance.new("Part")
    Part.BrickColor = PartColor
    Part.Size = PartSize
    
    Part.Position = Start + Vector3.new(PartSize.X * X, 0, PartSize.Z * Z)
    
    Part.Anchored = true
    Part.Parent = workspace
end

for X = 1, GridX do
    for Z = 1, GridZ do
        task.wait()
        CreatePart(X, Z)
    end
end

#

dont need to expleaned it the same script but cleaner