Hi! I have a script which "extends" a corridor by cloning itself and placing it on the end of the previous one. However, currently, it just pastes the corridor infront of the previous and stacks. Anyone have any ideas? Script:
while true do local infgen = game.Workspace:FindFirstChild("original"):Clone() local pos = infgen.PrimaryPart.CFrame * CFrame.new(0, 0, 334.464) wait(12) infgen.Name = "notorig" infgen:SetPrimaryPartCFrame(pos) wait(.4) infgen.Parent = game.Workspace end
Hey!
The mistake you are doing is you are always grabbing the CFrame from the original corridor, instead grabbing it from the latest created corridor.
I think this should fix it if I am not mistaken:
local AmountOfCorridors = 0 -- Add variable to define how much corridors you have cloned. while true do local infgen = game.Workspace:FindFirstChild("original"):Clone() infgen.Name = "notorig"..AmountOfCorridors -- Creating the model, always having a number behind it (notorig1, notorig2, notorig3, and so on...) local pos = game:Workspace:FindFirstChild("notorig"..AmountOfCorridors).PrimaryPart.CFrame * CFrame.new(0, 0, 334.464) -- Find the latest created corridor wait(.1) AmountOfCorridors = AmountOfCorridors+1 -- Adding +1 because we have created a new corridor. infgen:SetPrimaryPartCFrame(pos) wait(12) end
Let me know if this worked!
The code might not work, Im on mobile :p rename "original" model from workspace to "original0"
local nr = 0 while true do nr = nr + 1 local infgen= game.Workspace:FindFirstChild("original"..nr):Clone() local pos = infgen.PrimaryPart.CFrame * CFrame.new(0, 0, 334.464) wait(12) infgen.Name = "original" ..nr infgen:SetPrimaryPartCFrame(pos) wait(.4) infgen.Parent = game.Workspace end
Edit: it was alr answered