Add more objects in Region3

How do I cast more objects in region3 I have tried table insert and and params but I still do not know how add more than one object in the region3 ignore list. Any help would be great sine I do not know

local PartsToIgnore = {} -- would not work says unable to cast value to object
table.insert(PartsToIgnore, part)
table.insert(PartsToIgnore, Character)

for _,hit in pairs(workspace:FindPartsInRegion3(region, Character, 20)) do
      print(hit)
end

Workspace:FindPartsInRegion3WithIgnoreList (roblox.com)

local ignoreList = {}
table.insert(ignoreList, part)
table.insert(ignoreList, Character)


for _,hit in pairs(workspace:FindPartsInRegion3WithIgnoreList(region, ignoreList, 20)) do
    print(hit)
end

That is basically what I used but anyways thanks for the help.

so whats your problem?


I tried it and it won’t work the error is: unable to cast value to object

send the entire script you, have something else going on

local PartsToIgnore = {} -- would not work says unable to cast value to object
table.insert(PartsToIgnore, part)
table.insert(PartsToIgnore, Character)

for _,hit in pairs(workspace:FindPartsInRegion3WithIgnoreList(region, PartsToIgnore, 20)) do
      print(hit)
end
Tool.Activated:Connect(function()
	if not debounce then
		debounce = true
		local Character = Tool.Parent		
		local player = game.Players:GetPlayerFromCharacter(Character)
		local Humanoid = Character:WaitForChild("Humanoid")
		local rootpart = Character:WaitForChild("HumanoidRootPart")
		local Hand = Character:WaitForChild("RightHand")
		if Humanoid and rootpart and Hand then
local part = Instance.new("Part", ReflectFolder)
			debris:AddItem(part, 9.3)
			debris:AddItem(FF, 9.3)
		part.CanCollide = false
			part.Transparency = .5
			part.Shape = Enum.PartType.Block--Ball
			part.Material = Enum.Material.SmoothPlastic
			local physProperties = PhysicalProperties.new(.01, .1, 1, 1, 1)
			part.CustomPhysicalProperties = physProperties
			part.Massless = true
			local weld = Instance.new("Weld")
			weld.Parent = part
			weld.Part0 = part
			weld.Part1 = rootpart--Tool.Handle
			part.Size = Vector3.new(9,6,12)--Ball: Vector3.new(13,13,13)--,,,Vector3.new(3.4, 3.4, 9.4) --2.6
			weld.C0 = CFrame.new(0,0,4) --CFrame.new(0,0,-6.8)-- -9.4
			local Deflected = {}
			spawn(function()
				while debounce == true do
					local Larger = part.Size + Vector3.new(3,3,3)
					local min = part.Position - (0.5 * Larger)
					local max = part.Position + (0.5 * Larger)
					local region = Region3.new(min, max)
					local ignoreList = {}
					table.insert(ignoreList, part)
					table.insert(ignoreList, Character)
					--[[spawn(function()
						return workspace:FindPartsInRegion3WithIgnoreList(region, PartsToIgnore, 20)
					end)]]
					--workspace:FindPartsInRegion3(region, Character, 20)
					for _,hit in pairs(workspace:FindPartsInRegion3(region, Character, 20)) do
						print(hit)
						Tool.Rekt:Play()
						local ProjOwner 

						local Reflectable = true 
						for _,parts in pairs(hit:GetConnectedParts(true)) do
							if parts.Anchored then
								Reflectable = false
							end
						end
						spawn(function()
							Deflected[#Deflected+1] = hit
							wait(1)
							for index,v in pairs(Deflected) do
								if v == hit then
									table.remove(Deflected,index)
								end
							end
						end)

						ProjOwner = GetOwnerOfProjectile(hit, Character)

						if not ProjOwner then
							local NPCs,Players = TrackCharacters(part,500, Character)
							local PriorityTorso = GetNearestTorso(part.CFrame.p,{unpack(NPCs),unpack(Players)})
							ProjOwner = (PriorityTorso and PriorityTorso.Parent ~= Character and PriorityTorso.Parent) or nil
						end

						for _,forces in pairs(hit:GetDescendants()) do

							if forces:IsA("BodyVelocity") then
								if ProjOwner then
									forces.Velocity = CFrame.new(hit.CFrame.p,(ProjOwner:FindFirstChild("HumanoidRootPart") or ProjOwner:FindFirstChild("Torso") or ProjOwner:FindFirstChild("UpperTorso")).CFrame.p).lookVector * forces.Velocity.magnitude --((forces.Velocity.magnitude < 10 and 50) or forces.Velocity.magnitude) * 2
									print(ProjOwner)
								else -- Reflect back the opposite direction instead
									print("No ProjOwner")
									forces.Velocity =  forces.Velocity.unit * -forces.Velocity.magnitude
								end
							elseif forces:IsA("BodyGyro") then
								if ProjOwner then
									forces.CFrame = CFrame.new(hit.CFrame.p,(ProjOwner:FindFirstChild("HumanoidRootPart") or ProjOwner:FindFirstChild("Torso") or ProjOwner:FindFirstChild("UpperTorso")).CFrame.p)
								else -- Reflect back the opposite direction instead
									forces.CFrame = CFrame.new(hit.CFrame.p,hit.CFrame.p + hit.Velocity)
								end				
							elseif forces:IsA("RocketPropulsion") then
								if forces.Target and ProjOwner then
									forces.Target = ProjOwner:FindFirstChild("HumanoidRootPart") or ProjOwner:FindFirstChild("Torso") or ProjOwner:FindFirstChild("UpperTorso")
									forces.MaxSpeed = forces.MaxSpeed --* 2
									forces:Fire()
								else
									forces:Destroy() -- nothing to do with the rocket force
								end
							else
								if forces:IsA("BodyMover") then
									forces:Destroy()
								end
							end
						end
					end --  ignore part
					wait(.1)
				end
			end)
	wait(10)
		debounce = false
	end
end)

Can you upload a model of the complete tool, its harder to read it on the forum

also see:
Search results for ‘unable to cast value to object’ - DevForum | Roblox