Hi! I previously asked how to clone corridors and i got some good responses, however, the script now seems to give me the error of:
10:33:26.279 Workspace.Script:7: attempt to index nil with 'PrimaryPart' - Server - Script:7
The script used:
local AmountOfCorridors = 0 while true do local infgen = game.Workspace:FindFirstChild("original"):Clone() infgen.Name = "notorig"..AmountOfCorridors 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 infgen:SetPrimaryPartCFrame(pos) wait(12) end
Anyone have ideas? Thanks is advance!
If it is a model, then just change PrimaryPart, if not then this code should be good
local AmountOfCorridors = 0 while true do local infgen = game.Workspace:FindFirstChild("original"):Clone() infgen.Name = "notorig"..AmountOfCorridors if infgen:IsA("Model") then if infgen.PrimaryPart then local pos = game.Workspace:FindFirstChild("notorig"..AmountOfCorridors).PrimaryPart.CFrame * CFrame.new(0, 0, 334.464) -- Find the latest created corridor end elseif infgen:IsA("BasePart") then local pos = game.Workspace:FindFirstChild("notorig"..AmountOfCorridors).CFrame * CFrame.new(0, 0, 334.464) -- Find the latest created corridor end wait(.1) AmountOfCorridors = AmountOfCorridors+1 infgen:SetPrimaryPartCFrame(pos) wait(12) end