Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

" Workspace.Part.PhysicalShadow:49: attempt to index nil with 'Name'"?

Asked by 3 years ago

Working on something to create shadows (the details don't matter to much so I won't post them) but long story short I am trying to get a list of all bricks touching the physical shadow without counting bricks that are also shadows, and every time during the list it counts "nil" as part of the list

Heres the code if that helps

local brickstouching = shadow:GetTouchingParts()
print("printing list")
for i=1,#brickstouching do
    print(brickstouching[i])
    if brickstouching[i].Name == "PhysicalShadow" or brickstouching[i].Name == "shadowunionbrick" then
        table.remove(brickstouching,i)  
    end 
end

1 answer

Log in to vote
0
Answered by 3 years ago

Hello! I went ahead and changed the for loop, but I am unsure if the code will work for your situation. Attached is what I came up with, so let me know if you have any errors in the output!

local brickstouching = script.Parent:GetTouchingParts()

for i, part in ipairs(brickstouching) do
    print(part)
    if part.Name == "PhysicalShadow" or part.Name == "shadowunionbrick" then
        table.remove(brickstouching,i)  
    end 
end
Ad

Answer this question