Is there a way to detect if a part is blocking line of sight in this detection script?

Greetings, I am unsure whether or not it’s possible to detect if a part is in the way, but if there is, how would I do it?

Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		while Enemy.Humanoid.Health > 0 and wait() do
			local EnemyToCharacter = (Character.Head.Position - Enemy.Head.Position).Unit
			local EnemyVision = Enemy.Head.CFrame.LookVector

			local DotProduct = EnemyToCharacter:Dot(EnemyVision)

			if DotProduct > 0.5 then
				
			end
		end
	end)
end)

Try using raycasts
https://create.roblox.com/docs/mechanics/raycasting