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:
01 | local AmountOfCorridors = 0 |
02 |
03 | while true do |
04 | local infgen = game.Workspace:FindFirstChild( "original" ):Clone() |
05 | infgen.Name = "notorig" ..AmountOfCorridors |
06 | local pos = |
07 | game:Workspace:FindFirstChild( "notorig" ..AmountOfCorridors).PrimaryPart.CFrame * CFrame.new( 0 , 0 , 334.464 ) -- Find the latest created corridor |
08 |
09 | wait(. 1 ) |
10 |
11 | AmountOfCorridors = AmountOfCorridors+ 1 |
12 | infgen:SetPrimaryPartCFrame(pos) |
13 | wait( 12 ) |
14 | end |
Anyone have ideas? Thanks is advance!
If it is a model, then just change PrimaryPart, if not then this code should be good
01 | local AmountOfCorridors = 0 |
02 |
03 | while true do |
04 | local infgen = game.Workspace:FindFirstChild( "original" ):Clone() |
05 | infgen.Name = "notorig" ..AmountOfCorridors |
06 | if infgen:IsA( "Model" ) then |
07 | if infgen.PrimaryPart then |
08 | local pos = |
09 | game.Workspace:FindFirstChild( "notorig" ..AmountOfCorridors).PrimaryPart.CFrame * CFrame.new( 0 , 0 , 334.464 ) -- Find the latest created corridor |
10 | end |
11 | elseif infgen:IsA( "BasePart" ) then |
12 | local pos = |
13 | game.Workspace:FindFirstChild( "notorig" ..AmountOfCorridors).CFrame * CFrame.new( 0 , 0 , 334.464 ) -- Find the latest created corridor |
14 | end |
15 |