So basically Im trying to create a part after the part I specify to be cloned, but then I clone the clone of that part and then move it accordingly
I dont want to have do this for every single part I want to spawn and position after the last one
for i = 1, 1 do
local gridPart = part:Clone()
gridPart.Parent = workspace
gridPart.Position = gridPart.Position + Vector3.new(0,0,-part.Size.Z)
for i = 1,1 do
local gridPart2 = gridPart:Clone()
gridPart2.Parent = workspace
gridPart2.Position = gridPart2.Position + Vector3.new(0,0,-part.Size.Z)
for i = 1,1 do
local gridPart3 = gridPart2:Clone()
gridPart3.Parent = workspace
gridPart3.Position = gridPart3.Position + Vector3.new(0,0,-part.Size.Z)
end
end
end
local function setPartClone(part)
local gridPart = part:Clone()
gridPart.Parent = workspace
gridPart.Position = gridPart.Position + Vector3.new(0,0,-part.Size.Z)
return gridPart
end
And when you need to use it, just reference the part you want to clone, in this case
for i = 1, 1 do
local gridPart = setPartClone(part)
for i = 1,1 do
local gridPart2 = setPartClone(gridPart)
for i = 1,1 do
local gridPart3 = setPartClone(gridPart2)
end
end
end
Okay so I made a rough method of what you’re trying and for some reason it’s working for me without any changes, what’s happening when you try it? Could you show me a picture
for i = 1, 1 do
local gridPart = setPartClone(part)
for i = 1,1 do
local gridPart2 = setPartClone(gridPart)
for i = 1,1 do
local gridPart3 = setPartClone(gridPart2)
end
end
end
All the time
I want to make the script know what the last part was and do it accordingly but I just cant wrap my head around how I would do that
local part = workspace.Part
local function setPartClone(part)
local gridPart = part:Clone()
gridPart.Parent = workspace
gridPart.Position = gridPart.Position + Vector3.new(0,0,-part.Size.Z)
return gridPart
end
for i = 1, 4 do
part = setPartClone(part)
end
Instead of doing all of that, can’t you do something like
local amountX = 30
local amountZ = 30
local startingPosition = Vector3.new(0,.3,0)
local colors = {Color3.fromRGB(128, 187, 219),Color3.fromRGB(84, 123, 144)}
local colorPoint = 1
for x = 1,amountX do
for z = 1,amountZ do
if colorPoint >= #colors then
colorPoint = 1
else
colorPoint +=1
end
local part = game.ReplicatedStorage.gridPart:Clone()
part.Position = startingPosition + Vector3.new(x*part.Size.X,0,z*part.Size.Z)
part.Color = colors[colorPoint]
part.Parent = workspace
end
if colorPoint >= #colors then
colorPoint = 1
else
colorPoint +=1
end
end