Part bounding boxes for custom movement

So, I have multiple parts, but I want them to be walls, I have this really simplistic movement script, any help?

Right now, I’m using this for loop but whenever you press WASD it puts you inside the bounding boxes, I do not want this to happen.

I think it has something to do with the for loop, because when it was just one bounding box this did not happen.

local UIS = game:GetService("UserInputService")

while wait() do
	if UIS:IsKeyDown(Enum.KeyCode.W) then
		workspace.Human:PivotTo(workspace.Human.PrimaryPart.CFrame * CFrame.new(0, 1, 0))
		for i, boundingbox in pairs(workspace.Bounds:GetChildren()) do
			local PosY = math.clamp(workspace.Human.PrimaryPart.Position.Y, boundingbox.Position.Y - boundingbox.Size.Y/2, boundingbox.Position.Y + boundingbox.Size.Y/2)
			workspace.Human:PivotTo(CFrame.new(workspace.Human.PrimaryPart.Position.Y, PosY, workspace.Human.PrimaryPart.Position.Y))
		end
	elseif UIS:IsKeyDown(Enum.KeyCode.A) then
		workspace.Human:PivotTo(workspace.Human.PrimaryPart.CFrame * CFrame.new(-1, 0, 0))
		for i, boundingbox in pairs(workspace.Bounds:GetChildren()) do
			local PosX = math.clamp(workspace.Human.PrimaryPart.Position.X, boundingbox.Position.X - boundingbox.Size.X/2, boundingbox.Position.X + boundingbox.Size.X/2)
			workspace.Human:PivotTo(CFrame.new(workspace.Human.PrimaryPart.Position.X, PosX, workspace.Human.PrimaryPart.Position.X))
		end
	elseif UIS:IsKeyDown(Enum.KeyCode.S) then
		workspace.Human:PivotTo(workspace.Human.PrimaryPart.CFrame * CFrame.new(0, -1, 0))
		for i, boundingbox in pairs(workspace.Bounds:GetChildren()) do
			local PosY = math.clamp(workspace.Human.PrimaryPart.Position.Y, boundingbox.Position.Y - boundingbox.Size.Y/2, boundingbox.Position.Y + boundingbox.Size.Y/2)
			workspace.Human:PivotTo(CFrame.new(workspace.Human.PrimaryPart.Position.Y, PosY, workspace.Human.PrimaryPart.Position.Y))
		end
	elseif UIS:IsKeyDown(Enum.KeyCode.D) then
		workspace.Human:PivotTo(workspace.Human.PrimaryPart.CFrame * CFrame.new(1, 0, 0))
		for i, boundingbox in pairs(workspace.Bounds:GetChildren()) do
			local PosX = math.clamp(workspace.Human.PrimaryPart.Position.X, boundingbox.Position.X - boundingbox.Size.X/2, boundingbox.Position.X + boundingbox.Size.X/2)
			workspace.Human:PivotTo(CFrame.new(workspace.Human.PrimaryPart.Position.X, PosX, workspace.Human.PrimaryPart.Position.X))
		end
	end
end