I am trying to spawn each block on top of each other, it worked for the first block but then started spawning in each other.
I have tried adding waits, and adding more things to make it more specific, but with no result.
^ As you can see the grey blocks are spawning in each other.
Script:
wait(15)
local height = 5
local waitTime = 2
local towerPosition = Vector3.new(0,0,0)
local TowerPeices = game.ServerStorage.TowerCreator.TowerPeices:GetChildren()
local TowerBases = game.ServerStorage.TowerCreator.TowerBases:GetChildren()
local baseCreated = false
local previousPeice
for i = height, 0, -1 do
if baseCreated == false then
local base = TowerBases[math.random(1,#TowerBases)]:Clone()
base.PrimaryPart.CFrame = CFrame.new(towerPosition)
base.Parent = workspace
baseCreated = true
previousPeice = base
elseif baseCreated == true then
local towerPiece = TowerPeices[math.random(1,#TowerPeices)]:Clone()
towerPiece.PrimaryPart.CFrame = CFrame.new(previousPeice.PrimaryPart.CFrame.UpVector*(previousPeice.PrimaryPart.Size*Vector3.new(1,1,1)))
towerPiece.Parent = workspace
previousPeice = towerPiece
end
wait(waitTime)
end
Ps: The Blue piece is the tower base