Raycast only working on one item inside of an pairs table

My goal is to have a TextLabel presented to the screen while the player is inside of a circle. I have used collection service to include all the circles in the game for optimisation however the raycast seems to only work on a random circle only.

local InCircle = false

for _,circle in CollectionService:GetTagged("InteractionCircle") do
	RunService.Heartbeat:Connect(function ()
		local downcast = Ray.new(Character.HumanoidRootPart.CFrame.Position, Vector3.new(0, -5, 0))
		local part = workspace:FindPartOnRayWithWhitelist(downcast, {circle})


		if part then
			if InCircle == false then
				InterfaceModule.PromptFunction("Press E to claim this nest", true)
				InCircle = true
			end
		else
			InCircle = false
			InterfaceModule.PromptFunction(nil, false)
		end
	end)
end
for _,circle in CollectionService:GetTagged("InteractionCircle") do
local InCircle = false
	RunService.Heartbeat:Connect(function ()
		local downcast = Ray.new(Character.HumanoidRootPart.CFrame.Position, Vector3.new(0, -5, 0))
		local part = workspace:FindPartOnRayWithWhitelist(downcast, {circle})


		if part then
			if InCircle == false then
				InterfaceModule.PromptFunction("Press E to claim this nest", true)
				InCircle = true
			end
		else
			InCircle = false
			InterfaceModule.PromptFunction(nil, false)
		end
	end)
end

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