I’m trying to clone parts and get them on the right position with the right color partren cause they have a patren but it doesn’t work for some reason row 4 gets deleted instead of copied or the name of 4 turns into 5, but for sure it doesnt work here is the script and the workspace can someone please help me!?!
heres the workspace
and heres part of the script:
local playerAmount = #game:GetService("Players"):GetPlayers()
local calculationRowsAmount = playerAmount / 1.7
local calculatingRowsAmount = playerAmount * 2
local calculatorRowsAmount = calculatingRowsAmount - calculationRowsAmount
local finalRowsAmount = math.ceil(calculatorRowsAmount)
local amountRows = #platesFolder:GetChildren()
repeat
local newAmountRows = #platesFolder:GetChildren()
local rowToClone = platesFolder:FindFirstChild("Row"..tostring(newAmountRows))
local rowClone = rowToClone:Clone()
rowToClone.Name = "Row"..newAmountRows + 1
rowToClone.Parent = platesFolder
print("Aplied Settings")
for i,v in pairs(rowClone:GetChildren()) do
if v.Name == "Row" then
v.Value += 1
elseif v.Name == "Plate" then
local currentPlate = v
local currentLine = v.Line.Value
local thisRow = v.Parent.Row.Value
local colorRowToSearch = thisRow - 2
local otherColorModel = platesFolder:FindFirstChild("Row"..tostring(colorRowToSearch))
local positionRowToSearch = thisRow - 1
local otherPositionModel = platesFolder:FindFirstChild("Row"..tostring(positionRowToSearch))
for i,v in pairs(otherPositionModel:GetChildren()) do
if v.Name == "Plate" then
for i,v in pairs(v:GetChildren()) do
if v.Name == "Line" then
if v.Value == currentLine then
local otherPositionPart = v.Parent
local newPositionX = otherPositionPart.Position.X + 9
local newPositionY = otherPositionPart.Position.Y
local newPositionZ = otherPositionPart.Position.Z
currentPlate.CFrame = CFrame.new(newPositionX, newPositionY, newPositionZ)
end
end
end
end
end
-- check form here
for i,v in pairs(v:GetChildren()) do
if v.Name == "Line" then
for i,v in pairs(otherColorModel:GetChildren()) do
if v.Name == "Plate" then
for i,v in pairs(v:GetChildren()) do
if v.Name == "Line" then
if v.Value == currentLine then
local otherColorPart = v.Parent
currentPlate.Color = otherColorPart.Color
end
end
end
end
end
end
end
end
end
wait(0.5)
until #platesFolder:GetChildren() == finalRowsAmount