Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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

This discussion is preserved as it was. New answers, comments, and votes are closed.