Nuke not detecting all parts

I’m coding a nuke and I want it to turn any part it touches into corroded metal, however it’s only turning very specific parts into metal.

Code:

for i = 1,100 do
	wait()
	local Parts = script.Parent:GetTouchingParts()
	print(Parts)
	for i, v in pairs(Parts) do
		v.Material = Enum.Material.CorrodedMetal
	end
	
	script.Parent.Size += Vector3.new(10, 10, 10)
end
script.Parent:Destroy()

Images:
Screenshot 2024-09-21 135600
Screenshot 2024-09-21 135619
Screenshot 2024-09-21 135639

Any help would be appreciated.

Hm, have you tried GetPartBoundsInBox/GetPartBoundsInRadius/GetPartsInPart?
Source: Introducing OverlapParams - New Spatial Query API

2 Likes

Use :GetPartsInPart() and don’t loop through it 100 times, you already loop through all the parts it hit, so doing it 100 more times isn’t necessary.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.